8300821: UB: Applying non-zero offset to non-null pointer 0xfffffffffffffffe produced null pointer

Reviewed-by: kvn, thartmann
This commit is contained in:
Tobias Holenstein 2023-03-10 15:39:45 +00:00
parent 6d30bbe62c
commit 01312a002b
2 changed files with 4 additions and 3 deletions

View File

@ -523,7 +523,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()) continue; // skip trivial section
if (cs->is_empty() || !cs->has_locs()) continue; // skip trivial section
RelocIterator iter(cs);
while (iter.next()) {
if (iter.type() == relocInfo::metadata_type) {
@ -791,7 +791,7 @@ void CodeBuffer::relocate_code_to(CodeBuffer* dest) const {
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()) continue; // skip trivial section
if (cs->is_empty() || !cs->has_locs()) continue; // skip trivial section
CodeSection* dest_cs = dest->code_section(n);
{ // Repair the pc relative information in the code after the move
RelocIterator iter(dest_cs);

View File

@ -149,7 +149,8 @@ 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");
_current = cs->locs_start()-1;
_end = cs->locs_end();
_addr = cs->start();