Skip to content

Commit 664c993

Browse files
Vladimir Kozlovxmas92dean-long
committed
8331731: ubsan: relocInfo.cpp:155:30: runtime error: applying non-zero offset to null pointer
Co-authored-by: Axel Boldt-Christmas <[email protected]> Co-authored-by: Dean Long <[email protected]> Reviewed-by: mdoerr, thartmann, mbaesken
1 parent 8d3de45 commit 664c993

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/hotspot/share/asm/codeBuffer.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ void CodeBuffer::finalize_oop_references(const methodHandle& mh) {
525525
for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
526526
// pull code out of each section
527527
CodeSection* cs = code_section(n);
528-
if (cs->is_empty() || !cs->has_locs()) continue; // skip trivial section
528+
if (cs->is_empty() || (cs->locs_count() == 0)) continue; // skip trivial section
529529
RelocIterator iter(cs);
530530
while (iter.next()) {
531531
if (iter.type() == relocInfo::metadata_type) {
@@ -791,10 +791,8 @@ void CodeBuffer::relocate_code_to(CodeBuffer* dest) const {
791791
// call) is relocated. Stubs are placed behind the main code
792792
// section, so that section has to be copied before relocating.
793793
for (int n = (int) SECT_FIRST; n < (int)SECT_LIMIT; n++) {
794-
// pull code out of each section
795-
const CodeSection* cs = code_section(n);
796-
if (cs->is_empty() || !cs->has_locs()) continue; // skip trivial section
797794
CodeSection* dest_cs = dest->code_section(n);
795+
if (dest_cs->is_empty() || (dest_cs->locs_count() == 0)) continue; // skip trivial section
798796
{ // Repair the pc relative information in the code after the move
799797
RelocIterator iter(dest_cs);
800798
while (iter.next()) {
@@ -1057,7 +1055,7 @@ void CodeSection::print(const char* name) {
10571055
name, p2i(start()), p2i(end()), p2i(limit()), size(), capacity());
10581056
tty->print_cr(" %7s.locs = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d) point=%d",
10591057
name, p2i(locs_start()), p2i(locs_end()), p2i(locs_limit()), locs_size, locs_capacity(), locs_point_off());
1060-
if (PrintRelocations) {
1058+
if (PrintRelocations && (locs_size != 0)) {
10611059
RelocIterator iter(this);
10621060
iter.print();
10631061
}

src/hotspot/share/code/relocInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ void RelocIterator::initialize(nmethod* nm, address begin, address limit) {
150150

151151
RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) {
152152
initialize_misc();
153-
assert(((cs->locs_start() != nullptr) && (cs->locs_end() != nullptr)) ||
154-
((cs->locs_start() == nullptr) && (cs->locs_end() == nullptr)), "valid start and end pointer");
153+
assert(((cs->locs_start() != nullptr) && (cs->locs_end() != nullptr)), "valid start and end pointer");
155154
_current = cs->locs_start()-1;
156155
_end = cs->locs_end();
157156
_addr = cs->start();

0 commit comments

Comments
 (0)