Skip to content

Commit

Permalink
8331731: ubsan: relocInfo.cpp:155:30: runtime error: applying non-zer…
Browse files Browse the repository at this point in the history
…o offset to null pointer

Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org>
Co-authored-by: Dean Long <dlong@openjdk.org>
Reviewed-by: mdoerr, thartmann, mbaesken
  • Loading branch information
3 people committed Jun 4, 2024
1 parent 8d3de45 commit 664c993
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/hotspot/share/asm/codeBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ void CodeBuffer::finalize_oop_references(const methodHandle& mh) {
for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
// pull code out of each section
CodeSection* cs = code_section(n);
if (cs->is_empty() || !cs->has_locs()) continue; // skip trivial section
if (cs->is_empty() || (cs->locs_count() == 0)) continue; // skip trivial section
RelocIterator iter(cs);
while (iter.next()) {
if (iter.type() == relocInfo::metadata_type) {
Expand Down Expand Up @@ -791,10 +791,8 @@ void CodeBuffer::relocate_code_to(CodeBuffer* dest) const {
// call) is relocated. Stubs are placed behind the main code
// section, so that section has to be copied before relocating.
for (int n = (int) SECT_FIRST; n < (int)SECT_LIMIT; n++) {
// pull code out of each section
const CodeSection* cs = code_section(n);
if (cs->is_empty() || !cs->has_locs()) continue; // skip trivial section
CodeSection* dest_cs = dest->code_section(n);
if (dest_cs->is_empty() || (dest_cs->locs_count() == 0)) continue; // skip trivial section
{ // Repair the pc relative information in the code after the move
RelocIterator iter(dest_cs);
while (iter.next()) {
Expand Down Expand Up @@ -1057,7 +1055,7 @@ void CodeSection::print(const char* name) {
name, p2i(start()), p2i(end()), p2i(limit()), size(), capacity());
tty->print_cr(" %7s.locs = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d) point=%d",
name, p2i(locs_start()), p2i(locs_end()), p2i(locs_limit()), locs_size, locs_capacity(), locs_point_off());
if (PrintRelocations) {
if (PrintRelocations && (locs_size != 0)) {
RelocIterator iter(this);
iter.print();
}
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/code/relocInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ void RelocIterator::initialize(nmethod* nm, address begin, address limit) {

RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) {
initialize_misc();
assert(((cs->locs_start() != nullptr) && (cs->locs_end() != nullptr)) ||
((cs->locs_start() == nullptr) && (cs->locs_end() == nullptr)), "valid start and end pointer");
assert(((cs->locs_start() != nullptr) && (cs->locs_end() != nullptr)), "valid start and end pointer");
_current = cs->locs_start()-1;
_end = cs->locs_end();
_addr = cs->start();
Expand Down

3 comments on commit 664c993

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member

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 664c993 Aug 1, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 664c993c to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/hotspot/share/code/relocInfo.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-664c993c-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 664c993c41753843293388a6ff1481a94a5b4c22

# Backport the commit
$ git cherry-pick --no-commit 664c993c41753843293388a6ff1481a94a5b4c22
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 664c993c41753843293388a6ff1481a94a5b4c22'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport 664c993c41753843293388a6ff1481a94a5b4c22.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 664c993c from the openjdk/jdk repository.

The commit being backported was authored by Vladimir Kozlov on 4 Jun 2024 and was reviewed by Martin Doerr, Tobias Hartmann and Matthias Baesken.

Thanks!

Please sign in to comment.