8352112: [ubsan] hotspot/share/code/relocInfo.cpp:130:37: runtime error: applying non-zero offset 18446744073709551614 to null pointer

Reviewed-by: dlong, bulasevich
This commit is contained in:
Vladimir Kozlov 2025-03-21 20:51:30 +00:00
parent c2e14b1b30
commit 22182f71ed

View File

@ -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)),
@ -151,6 +151,9 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
if (_mutable_data == nullptr) {
vm_exit_out_of_memory(_mutable_data_size, OOM_MALLOC_ERROR, "codebuffer: no space for mutable data");
}
} else {
// We need unique and valid not null address
assert(_mutable_data = blob_end(), "sanity");
}
set_oop_maps(oop_maps);
@ -160,7 +163,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t header_size) :
_oop_maps(nullptr),
_name(name),
_mutable_data(nullptr),
_mutable_data(header_begin() + size), // default value is blob_end()
_size(size),
_relocation_size(0),
_content_offset(CodeBlob::align_code_offset(header_size)),
@ -175,12 +178,14 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t heade
{
assert(is_aligned(size, oopSize), "unaligned size");
assert(is_aligned(header_size, oopSize), "unaligned size");
assert(_mutable_data = blob_end(), "sanity");
}
void CodeBlob::purge() {
if (_mutable_data != nullptr) {
assert(_mutable_data != nullptr, "should never be null");
if (_mutable_data != blob_end()) {
os::free(_mutable_data);
_mutable_data = nullptr;
_mutable_data = blob_end(); // Valid not null address
}
if (_oop_maps != nullptr) {
delete _oop_maps;