Integrated: 8346193: CrashGCForDumpingJavaThread do not trigger expected crash build with clang17
SendaoYan
syan at openjdk.org
Thu Jan 2 09:12:40 UTC 2025
On Mon, 16 Dec 2024 09:53: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
This pull request has now been integrated.
Changeset: e769b536
Author: SendaoYan <syan at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/e769b53614b13e09ea575558be687607549f700b
Stats: 4 lines in 1 file changed: 0 ins; 3 del; 1 mod
8346193: CrashGCForDumpingJavaThread do not trigger expected crash build with clang17
Reviewed-by: kbarrett, amitkumar
-------------
PR: https://git.openjdk.org/jdk/pull/22757
More information about the hotspot-dev
mailing list