RFR: 8352112: [ubsan] hotspot/share/code/relocInfo.cpp:130:37: runtime error: applying non-zero offset 18446744073709551614 to null pointer
Vladimir Kozlov
kvn at openjdk.org
Tue Mar 18 22:21:06 UTC 2025
On Tue, 18 Mar 2025 18:35:06 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
> Before [JDK-8343789](https://bugs.openjdk.org/browse/JDK-8343789) `relocation_begin()` was never null even when there was no relocations - it pointed to the beginning of constant or code section in such case. It was used by relocation code to simplify code and avoid null checks.
> With that fix `relocation_begin()` points to address in `CodeBlob::_mutable_data` field which could be `nullptr` if there is no relocation and metadata.
>
> There easy fix is to avoid `nullptr` in `CodeBlob::_mutable_data`. We could do that similar to what we do for `nmethod::_immutable_data`: [nmethod.cpp#L1514](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/code/nmethod.cpp#L1514).
>
> Tested tier1-4, stress, xcomp. Verified with failed tests listed in bug report.
Actually I can do this (in both constructors):
+++ b/src/hotspot/share/code/codeBlob.cpp
@@ -121,7 +121,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
int mutable_data_size) :
_oop_maps(nullptr), // will be set by set_oop_maps() call
_name(name),
- _mutable_data(nullptr),
+ _mutable_data(header_begin() + size), // default value is blob_end()
_size(size),
_relocation_size(align_up(cb->total_relocation_size(), oopSize)),
_content_offset(CodeBlob::align_code_offset(header_size)),
@@ -153,7 +153,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
}
} else {
// We need unique and valid not null address
- _mutable_data = blob_end();
+ assert(_mutable_data == blob_end(), "sanity");
}
set_oop_maps(oop_maps);
What do you think?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24102#issuecomment-2734862556
More information about the hotspot-compiler-dev
mailing list