Skip to content

Commit dedcce0

Browse files
author
Vladimir Kozlov
committed
8360942: [ubsan] aotCache tests trigger runtime error: applying non-zero offset 16 to null pointer in CodeBlob::relocation_end()
Reviewed-by: adinn, mbaesken
1 parent 03526e2 commit dedcce0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/hotspot/share/code/codeBlob.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
160160
}
161161
} else {
162162
// We need unique and valid not null address
163-
assert(_mutable_data = blob_end(), "sanity");
163+
assert(_mutable_data == blob_end(), "sanity");
164164
}
165165

166166
set_oop_maps(oop_maps);
@@ -177,6 +177,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t heade
177177
_code_offset(_content_offset),
178178
_data_offset(size),
179179
_frame_size(0),
180+
_mutable_data_size(0),
180181
S390_ONLY(_ctable_offset(0) COMMA)
181182
_header_size(header_size),
182183
_frame_complete_offset(CodeOffsets::frame_never_safe),
@@ -185,7 +186,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t heade
185186
{
186187
assert(is_aligned(size, oopSize), "unaligned size");
187188
assert(is_aligned(header_size, oopSize), "unaligned size");
188-
assert(_mutable_data = blob_end(), "sanity");
189+
assert(_mutable_data == blob_end(), "sanity");
189190
}
190191

191192
void CodeBlob::restore_mutable_data(address reloc_data) {
@@ -195,8 +196,11 @@ void CodeBlob::restore_mutable_data(address reloc_data) {
195196
if (_mutable_data == nullptr) {
196197
vm_exit_out_of_memory(_mutable_data_size, OOM_MALLOC_ERROR, "codebuffer: no space for mutable data");
197198
}
199+
} else {
200+
_mutable_data = blob_end(); // default value
198201
}
199202
if (_relocation_size > 0) {
203+
assert(_mutable_data_size > 0, "relocation is part of mutable data section");
200204
memcpy((address)relocation_begin(), reloc_data, relocation_size());
201205
}
202206
}

src/hotspot/share/code/codeBlob.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class CodeBlob {
247247
// Sizes
248248
int size() const { return _size; }
249249
int header_size() const { return _header_size; }
250-
int relocation_size() const { return pointer_delta_as_int((address) relocation_end(), (address) relocation_begin()); }
250+
int relocation_size() const { return _relocation_size; }
251251
int content_size() const { return pointer_delta_as_int(content_end(), content_begin()); }
252252
int code_size() const { return pointer_delta_as_int(code_end(), code_begin()); }
253253

0 commit comments

Comments
 (0)