Skip to content

Commit

Permalink
8331626: unsafe.cpp:162:38: runtime error in index_oop_from_field_off…
Browse files Browse the repository at this point in the history
…set_long - applying non-zero offset 4563897424 to null pointer

Backport-of: 23a72a1f2f651d5e8e9a0eb1e75e2b44572a13da
  • Loading branch information
TheRealMDoerr committed Jun 11, 2024
1 parent 4deef75 commit e716aae
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/hotspot/share/prims/unsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,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:
Expand Down

0 comments on commit e716aae

Please sign in to comment.