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

8333887: ubsan: unsafe.cpp:247:13: runtime error: store to null pointer of type 'volatile int' #19630

Closed
wants to merge 1 commit into from

Conversation

MBaesken
Copy link
Member

@MBaesken MBaesken commented Jun 10, 2024

When running with ubsan enabled binaries, in a number of tests like
jdk/jfr/event/runtime/TestShutdownEvent.jtr
jdk/jfr/jvm/TestDumpOnCrash.jtr
we get those ubsan-errors :

src/hotspot/share/prims/unsafe.cpp:247:13: runtime error: store to null pointer of type 'volatile int'
#0 0x7f0be9a3e10d in MemoryAccess::put(int) src/hotspot/share/prims/unsafe.cpp:247
#1 0x7f0be9a3e10d in Unsafe_PutInt src/hotspot/share/prims/unsafe.cpp:315
#2 0x7f0bd0502e7b ()
#3 0x7f0bd04fe01f ()
#4 0x7f0bd04fe01f ()
#5 0x7f0bd04fe525 ()
#6 0x7f0bd04f6c85 ()
#7 0x7f0be80a2972 in JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*) src/hotspot/share/runtime/javaCalls.cpp:415
#8 0x7f0be83160d8 in jni_invoke_static src/hotspot/share/prims/jni.cpp:888
#9 0x7f0be831d875 in jni_CallStaticVoidMethod src/hotspot/share/prims/jni.cpp:1717
#10 0x7f0beed32cf8 in invokeStaticMainWithArgs src/java.base/share/native/libjli/java.c:418
#11 0x7f0beed35894 in JavaMain src/java.base/share/native/libjli/java.c:623
#12 0x7f0beed3cf68 in ThreadJavaMain src/java.base/unix/native/libjli/java_md.c:653
#13 0x7f0beeceb6e9 in start_thread (/lib64/libpthread.so.0+0xa6e9) (BuildId: 2f8d3c2d0f4d7888c2598d2ff6356537f5708a73)

Looks like we use unsafe to put/write to 0 e.g. to cause a crash. Probably we could add an attribute to the function so that ubsan stops complaining (the put to 0 is done for a reason but ubsan cannot know this).


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-8333887: ubsan: unsafe.cpp:247:13: runtime error: store to null pointer of type 'volatile int' (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19630

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 10, 2024

👋 Welcome back mbaesken! 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 Jun 10, 2024

@MBaesken This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8333887: ubsan: unsafe.cpp:247:13: runtime error: store to null pointer of type 'volatile int'

Reviewed-by: lucy, mdoerr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 47 new commits pushed to the master branch:

  • 9d8439c: 8211854: [aix] java/net/ServerSocket/AcceptInheritHandle.java fails: read times out
  • f521367: 8211847: [aix] java/lang/ProcessHandle/InfoTest.java fails: "reported cputime less than expected"
  • f8c657f: 8334123: log the opening of Type 1 fonts
  • 57b6481: 8333277: ubsan: mlib_ImageScanPoly.c:292:43: runtime error: division by zero
  • 5528ad7: 8334179: VMATreeTest.TestConsistencyWithSimpleTracker_vm runs 50+ seconds
  • 5d2a19d: 8333684: C2 SuperWord: multiple smaller refactorings in preparation for JDK-8332163
  • 301bd70: 8311110: multichar warning in WinAccessBridge.cpp
  • 238162a: 8322064: Remove expired flags in JDK 24
  • fcedde8: 8330846: Add stacks of mounted virtual threads to the HotSpot thread dump
  • 74468bc: 8209092: Remove outdated wording from RC5ParameterSpec
  • ... and 37 more: https://git.openjdk.org/jdk/compare/2a242db01ed1d502affa4a954e601266fa98dfbe...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8333887: ubsan: unsafe.cpp:247:13: runtime error: store to null pointer of type 'volatile int' 8333887: ubsan: unsafe.cpp:247:13: runtime error: store to null pointer of type 'volatile int' Jun 10, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 10, 2024
@openjdk
Copy link

openjdk bot commented Jun 10, 2024

@MBaesken 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 Jun 10, 2024
@mlbridge
Copy link

mlbridge bot commented Jun 10, 2024

Webrevs

Comment on lines +245 to +249
// we use this method at some places for writing to 0 e.g. to cause a crash;
// ubsan does not know that this is the desired behavior
#if defined(__clang__) || defined(__GNUC__)
__attribute__((no_sanitize("undefined")))
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Can we hide this in a macro like SUPPRESS_UBSAN_WARNING? If it turns out we need to do this in a few places then it will look nicer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds like a good idea. See also the discussion about ATTRIBUTE_NO_UBSAN here #19597

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea of an encapsulating macro as well.

Copy link
Member

Choose a reason for hiding this comment

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

I guess ATTRIBUTE_NO_UBSAN will do if we have a precedent for that naming.

Copy link
Contributor

@RealLucy RealLucy left a comment

Choose a reason for hiding this comment

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

LGTM.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 12, 2024
@MBaesken
Copy link
Member Author

Hi Lutz, thanks for the review !
I plan to do the ATTRIBUTE_NO_UBSAN change in a follow up for various code locations .

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

Fine with me if you do the macro thing later.

@MBaesken
Copy link
Member Author

Thanks for the reviews ! The 'macro thing' comes in a follow up.

/integrate

@openjdk
Copy link

openjdk bot commented Jun 13, 2024

Going to push as commit 0d3a377.
Since your change was applied there have been 47 commits pushed to the master branch:

  • 9d8439c: 8211854: [aix] java/net/ServerSocket/AcceptInheritHandle.java fails: read times out
  • f521367: 8211847: [aix] java/lang/ProcessHandle/InfoTest.java fails: "reported cputime less than expected"
  • f8c657f: 8334123: log the opening of Type 1 fonts
  • 57b6481: 8333277: ubsan: mlib_ImageScanPoly.c:292:43: runtime error: division by zero
  • 5528ad7: 8334179: VMATreeTest.TestConsistencyWithSimpleTracker_vm runs 50+ seconds
  • 5d2a19d: 8333684: C2 SuperWord: multiple smaller refactorings in preparation for JDK-8332163
  • 301bd70: 8311110: multichar warning in WinAccessBridge.cpp
  • 238162a: 8322064: Remove expired flags in JDK 24
  • fcedde8: 8330846: Add stacks of mounted virtual threads to the HotSpot thread dump
  • 74468bc: 8209092: Remove outdated wording from RC5ParameterSpec
  • ... and 37 more: https://git.openjdk.org/jdk/compare/2a242db01ed1d502affa4a954e601266fa98dfbe...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 13, 2024
@openjdk openjdk bot closed this Jun 13, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 13, 2024
@openjdk
Copy link

openjdk bot commented Jun 13, 2024

@MBaesken Pushed as commit 0d3a377.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Successfully merging this pull request may close these issues.

4 participants