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

Matthias Baesken mbaesken at openjdk.org
Wed Jun 12 07:05:14 UTC 2024


On Wed, 12 Jun 2024 01:46:57 GMT, David Holmes <dholmes 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).
>
> src/hotspot/share/prims/unsafe.cpp line 249:
> 
>> 247: #if defined(__clang__) || defined(__GNUC__)
>> 248: __attribute__((no_sanitize("undefined")))
>> 249: #endif
> 
> 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.

Sounds like a good idea.  See also the discussion about `ATTRIBUTE_NO_UBSAN`  here  https://github.com/openjdk/jdk/pull/19597

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19630#discussion_r1635921287


More information about the hotspot-dev mailing list