Skip to content

Commit

Permalink
8300821: UB: Applying non-zero offset to non-null pointer 0xfffffffff…
Browse files Browse the repository at this point in the history
…ffffffe produced null pointer

Reviewed-by: kvn, thartmann
  • Loading branch information
tobiasholenstein committed Mar 10, 2023
1 parent 6d30bbe commit 01312a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/asm/codeBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/code/relocInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

1 comment on commit 01312a0

@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.