-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8332818: ubsan: archiveHeapLoader.cpp:70:27: runtime error: applying non-zero offset 18446744073707454464 to null pointer #19597
Conversation
👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into |
@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:
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 81 new commits pushed to the
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 |
Webrevs
|
@@ -61,6 +61,10 @@ ptrdiff_t ArchiveHeapLoader::_mapped_heap_delta = 0; | |||
|
|||
// Every mapped region is offset by _mapped_heap_delta from its requested address. | |||
// See FileMapInfo::heap_region_requested_address(). | |||
// avoid adding to CompressedOops::base() == nullptr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what the comment is trying to say.
This is surely a bug in ubsan as I should be able to take any address, including zero, and add an offset to get another address!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi David, it is no ubsan-bug, see also here for more details about this warning https://reviews.llvm.org/D67122 .
@dholmes-ora Adding to NULL is undefined, Matthias is right there. E.g. I once worked on machines that tracked the validity of pointers in hardware. Adding anything to NULL would give you a hardware interrupt. However, that is not the case for any of our platforms. Which is why Matthias mutes UBSAN here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
But could you add a define for this, please? Would be better to read. We already have ATTRIBUTE_NO_ASAN (see share/sanitizers). I think a corresponding ATTRIBUTE_NO_UBSAN would be good.
Such a define would also be the central place to switch on Visual Studio if they ever add ubsan support.
Thanks for the review ! |
Thomas, could we do the ATTRIBUTE_NO_UBSAN in a follow up ? |
ubsan.hpp? |
Sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Hmm okay. So really our |
Well, not sure. C99:
The one platform I talked about (IBM AS/400 in native mode) did the latter. Casting integer to pointer resulted in an invalid pointer that would trap on dereferencing. Personally, I think hunting UB is sorting out the chaff to find the useful bits. Pity that we cannot selectivly switch off UB cases with the compiler, and have to decorate code instead. |
We can switch off whole ubsan problem/issue 'classes' (and do this already for some types of shifts). But this is of course not fine granular if done for the whole codebase. Btw any objections integrating this now (and doing in the follow up the ATTRIBUTE_NO_UBSAN macro, see https://bugs.openjdk.org/browse/JDK-8334239) ? |
no problem, but i would remove the comment about avoiding adding to null. |
I removed the comment. /integrate |
Going to push as commit 6861766.
Your commit was automatically rebased without conflicts. |
When running :tier1 hs tests, the following issue has been reported when running with ubsan enabled binaries (configure flag --enable-ubsan)
stderr: [/jdk/src/hotspot/share/cds/archiveHeapLoader.cpp:70:27: runtime error: applying non-zero offset 18446744073707454464 to null pointer
#0 0x7f33db52823f in ArchiveHeapLoader::init_mapped_heap_info(unsigned char*, long, int) /jdk/src/hotspot/share/cds/archiveHeapLoader.cpp:70
#1 0x7f33dc6d3ad4 in FileMapInfo::map_heap_region_impl() /jdk/src/hotspot/share/cds/filemap.cpp:2211
#2 0x7f33dc6d4ba4 in FileMapInfo::map_heap_region() /jdk/src/hotspot/share/cds/filemap.cpp:2129
#3 0x7f33dc6d52a7 in FileMapInfo::map_or_load_heap_region() /jdk/src/hotspot/share/cds/filemap.cpp:2019
#4 0x7f33ddaf7fdb in MetaspaceShared::map_archives(FileMapInfo*, FileMapInfo*, bool) /jdk/src/hotspot/share/cds/metaspaceShared.cpp:1183
#5 0x7f33ddaf8f54 in MetaspaceShared::initialize_runtime_shared_and_meta_spaces() /jdk/src/hotspot/share/cds/metaspaceShared.cpp:943
#6 0x7f33ddadd60f in Metaspace::global_initialize() /jdk/src/hotspot/share/memory/metaspace.cpp:714
#7 0x7f33de9bc7f9 in universe_init() /jdk/src/hotspot/share/memory/universe.cpp:866
#8 0x7f33dcc93691 in init_globals() /jdk/src/hotspot/share/runtime/init.cpp:128
#9 0x7f33de92a720 in Threads::create_vm(JavaVMInitArgs*, bool*) /jdk/src/hotspot/share/runtime/threads.cpp:553
#10 0x7f33dd02d477 in JNI_CreateJavaVM_inner /jdk/src/hotspot/share/prims/jni.cpp:3581
#11 0x7f33dd02d477 in JNI_CreateJavaVM /jdk/src/hotspot/share/prims/jni.cpp:3672
#12 0x7f33e42a90e5 in InitializeJVM /jdk/src/java.base/share/native/libjli/java.c:1550
#13 0x7f33e42a90e5 in JavaMain /jdk/src/java.base/share/native/libjli/java.c:491
#14 0x7f33e42b2748 in ThreadJavaMain /jdk/src/java.base/unix/native/libjli/java_md.c:642
#15 0x7f33e42616e9 in start_thread (/lib64/libpthread.so.0+0xa6e9) (BuildId: 2f8d3c2d0f4d7888c2598d2ff6356537f5708a73)
#16 0x7f33e391550e in clone (/lib64/libc.so.6+0x11850e) (BuildId: f732026552f6adff988b338e92d466bc81a01c37)
Seems that
CompressedOops::base()
can be nullptr , so adding to it some non-zero value triggers ubsan because of undefined behavior. In the JBS-bug there was already a little discussion and it seems disabling this warning might be an option.otherwise some workaround like
could be used .
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19597/head:pull/19597
$ git checkout pull/19597
Update a local copy of the PR:
$ git checkout pull/19597
$ git pull https://git.openjdk.org/jdk.git pull/19597/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19597
View PR using the GUI difftool:
$ git pr show -t 19597
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19597.diff
Webrev
Link to Webrev Comment