From 9cc6e8046108f27623b4480a19daa0937d7dcd5b Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Tue, 18 Mar 2025 10:47:44 -0700 Subject: [PATCH] [ubsan] hotspot/share/code/relocInfo.cpp:130:37: runtime error: applying non-zero offset 18446744073709551614 to null pointer --- src/hotspot/share/code/codeBlob.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/code/codeBlob.cpp b/src/hotspot/share/code/codeBlob.cpp index 79f6bf61ff171..fdcc74362f5cb 100644 --- a/src/hotspot/share/code/codeBlob.cpp +++ b/src/hotspot/share/code/codeBlob.cpp @@ -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 + _mutable_data = blob_end(); } set_oop_maps(oop_maps); @@ -175,12 +178,13 @@ 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"); + _mutable_data = blob_end(); // Valid not null address } void CodeBlob::purge() { - if (_mutable_data != nullptr) { + 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;