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

Reviewed-by: rschmelter
Backport-of: 664c993c41753843293388a6ff1481a94a5b4c22
  • Loading branch information
MBaesken committed Aug 2, 2024
1 parent ee21571 commit b79e185
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 @@ -524,7 +524,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 @@ -790,10 +790,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 @@ -1054,7 +1052,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 @@ -149,8 +149,7 @@ void RelocIterator::initialize(CompiledMethod* 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

1 comment on commit b79e185

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.