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

Martin Doerr mdoerr at openjdk.org
Thu Jun 13 14:00:22 UTC 2024


On Mon, 10 Jun 2024 13:52:15 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

> 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).

Fine with me if you do the macro thing later.

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

Marked as reviewed by mdoerr (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/19630#pullrequestreview-2115889145


More information about the hotspot-dev mailing list