8331626: unsafe.cpp:162:38: runtime error in index_oop_from_field_offset_long - applying non-zero offset 4563897424 to null pointer

Reviewed-by: mbaesken, stefank
This commit is contained in:
Martin Doerr 2024-05-07 08:32:48 +00:00
parent a2584a8341
commit 23a72a1f2f

@ -154,13 +154,9 @@ static inline void assert_field_offset_sane(oop p, jlong field_offset) {
static inline void* index_oop_from_field_offset_long(oop p, jlong field_offset) {
assert_field_offset_sane(p, field_offset);
jlong byte_offset = field_offset_to_byte_offset(field_offset);
if (sizeof(char*) == sizeof(jint)) { // (this constant folds!)
return cast_from_oop<address>(p) + (jint) byte_offset;
} else {
return cast_from_oop<address>(p) + byte_offset;
}
uintptr_t base_address = cast_from_oop<uintptr_t>(p);
uintptr_t byte_offset = (uintptr_t)field_offset_to_byte_offset(field_offset);
return (void*)(base_address + byte_offset);
}
// Externally callable versions: