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

Matthias Baesken mbaesken at openjdk.org
Mon Jun 10 13:57:48 UTC 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<int>::put(int) src/hotspot/share/prims/unsafe.cpp:247
    #1 0x7f0be9a3e10d in Unsafe_PutInt src/hotspot/share/prims/unsafe.cpp:315
    #2 0x7f0bd0502e7b (<unknown module>)
    #3 0x7f0bd04fe01f (<unknown module>)
    #4 0x7f0bd04fe01f (<unknown module>)
    #5 0x7f0bd04fe525 (<unknown module>)
    #6 0x7f0bd04f6c85 (<unknown module>)
    #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).

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

Commit messages:
 - JDK-8333887

Changes: https://git.openjdk.org/jdk/pull/19630/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19630&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8333887
  Stats: 5 lines in 1 file changed: 5 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/19630.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19630/head:pull/19630

PR: https://git.openjdk.org/jdk/pull/19630


More information about the hotspot-dev mailing list