Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8346193: Test runtime/ErrorHandling/TestDwarf.java fails build with clang17 #22757

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sendaoYan
Copy link
Member

@sendaoYan sendaoYan commented Dec 16, 2024

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 add volatile modifier to char *t, to make avoid clang do the "dead code" elimination. 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
  1. 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

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8346193: Test runtime/ErrorHandling/TestDwarf.java fails build with clang17 (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22757/head:pull/22757
$ git checkout pull/22757

Update a local copy of the PR:
$ git checkout pull/22757
$ git pull https://git.openjdk.org/jdk.git pull/22757/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22757

View PR using the GUI difftool:
$ git pr show -t 22757

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22757.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 16, 2024

👋 Welcome back syan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 16, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 16, 2024
@openjdk
Copy link

openjdk bot commented Dec 16, 2024

@sendaoYan The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Dec 16, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 16, 2024

Webrevs

@@ -1163,7 +1163,7 @@ void frame::oops_do_internal(OopClosure* f, NMethodClosure* cf,
#ifndef PRODUCT
// simulate GC crash here to dump java thread in error report
if (CrashGCForDumpingJavaThread) {
char *t = nullptr;
volatile char *t = nullptr; // Use volatile modifier to make clang avoid 'dead code' elimination
Copy link
Member

@dholmes-ora dholmes-ora Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
volatile char *t = nullptr; // Use volatile modifier to make clang avoid 'dead code' elimination
volatile char* t = nullptr; // Use volatile to prevent compiler from optimising away the store

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants