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

Reviewed-by: mbaesken, stefank
  • Loading branch information
TheRealMDoerr committed May 7, 2024
1 parent a2584a8 commit 23a72a1
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 @@ -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:
Expand Down

3 comments on commit 23a72a1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 23a72a1 Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr the backport was successfully created on the branch backport-TheRealMDoerr-23a72a1f-master in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 23a72a1f from the openjdk/jdk repository.

The commit being backported was authored by Martin Doerr on 7 May 2024 and was reviewed by Matthias Baesken and Stefan Karlsson.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-TheRealMDoerr-23a72a1f-master:backport-TheRealMDoerr-23a72a1f-master
$ git checkout backport-TheRealMDoerr-23a72a1f-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-TheRealMDoerr-23a72a1f-master

Please sign in to comment.