RFR: 8346193: CrashGCForDumpingJavaThread do not trigger expected crash build with clang17 [v6]

Christian Hagedorn chagedorn at openjdk.org
Mon Jan 6 08:04:41 UTC 2025


On Thu, 2 Jan 2025 03:11:08 GMT, SendaoYan <syan at openjdk.org> wrote:

>> Hi all,
>> Function `frame::oops_do_internal` in src/hotspot/share/runtime/frame.cpp assign value to a nullptr `char *t` and intended to cause jvm crash. But after the assignment the nullptr do not use anymore, so clang17 consider the `char *t` initialization and assignment is "dead code". This PR use function `guarantee` instead of 'write a byte to nullptr' to trigger the expected jvm crash, risk is low.
>> 
>> Here is the example explain the "dead code" elimination.
>> 
>> 1. Without volatile modifier, clang will delete the "dead code" and cause no more Segmentation fault error by -O1.
>> 
>> 
>>> cat demo.c 
>> int main() { char *t = 0; *t = 'c'; return 0; }
>>> clang -O0 demo.c && ./a.out ; echo $?
>> Segmentation fault (core dumped)
>> 139
>>> clang -O1 demo.c && ./a.out ; echo $?
>> 0
>> 
>> 
>> 2. With volatile modifier, clang do not delete the "dead code" again and and the expected Segmentation fault occur by -O1.
>> 
>>> cat demo.c 
>> int main() { volatile char *t = 0; *t = 'c'; return 0; }
>>> clang -O0 demo.c && ./a.out ; echo $?
>> Segmentation fault (core dumped)
>> 139
>>> clang -O1 demo.c && ./a.out ; echo $?
>> Segmentation fault (core dumped)
>> 139
>
> SendaoYan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove duplicate CrashGCForDumpingJavaThread check

Just as a side note, the idea of `TestDwarf.java` was to reliably crash the VM with as many different stack traces as possible - it does not really matter how the VM crashes.This gets us some sanity testing for the DWARF parser.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22757#issuecomment-2572509002


More information about the hotspot-dev mailing list