8331731: ubsan: relocInfo.cpp:155:30: runtime error: applying non-zero 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
This commit is contained in:
Vladimir Kozlov 2024-06-04 16:36:39 +00:00
parent 8d3de45f4d
commit 664c993c41
2 changed files with 4 additions and 7 deletions

View File

@ -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) {
@ -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()) {
@ -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();
}

View File

@ -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();