Skip to content

Commit

Permalink
8256258: some missing NULL checks or asserts after CodeCache::find_bl…
Browse files Browse the repository at this point in the history
…ob_unsafe

Reviewed-by: shade
  • Loading branch information
MBaesken committed Nov 17, 2020
1 parent 1228517 commit 4553fa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/hotspot/cpu/ppc/nativeInst_ppc.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019 SAP SE. All rights reserved.
* Copyright (c) 2012, 2020 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -177,6 +177,7 @@ void NativeFarCall::verify() {
address NativeMovConstReg::next_instruction_address() const {
#ifdef ASSERT
CodeBlob* nm = CodeCache::find_blob(instruction_address());
assert(nm != NULL, "Could not find code blob");
assert(!MacroAssembler::is_set_narrow_oop(addr_at(0), nm->content_begin()), "Should not patch narrow oop here");
#endif

Expand All @@ -195,6 +196,7 @@ intptr_t NativeMovConstReg::data() const {
}

CodeBlob* cb = CodeCache::find_blob_unsafe(addr);
assert(cb != NULL, "Could not find code blob");
if (MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) {
narrowOop no = MacroAssembler::get_narrow_oop(addr, cb->content_begin());
// We can reach here during GC with 'no' pointing to new object location
Expand Down Expand Up @@ -297,6 +299,7 @@ void NativeMovConstReg::set_data(intptr_t data) {
void NativeMovConstReg::set_narrow_oop(narrowOop data, CodeBlob *code /* = NULL */) {
address inst2_addr = addr_at(0);
CodeBlob* cb = (code) ? code : CodeCache::find_blob(instruction_address());
assert(cb != NULL, "Could not find code blob");
if (MacroAssembler::get_narrow_oop(inst2_addr, cb->content_begin()) == data) {
return;
}
Expand Down Expand Up @@ -403,6 +406,7 @@ address NativeCallTrampolineStub::encoded_destination_addr() const {

address NativeCallTrampolineStub::destination(nmethod *nm) const {
CodeBlob* cb = nm ? nm : CodeCache::find_blob_unsafe(addr_at(0));
assert(cb != NULL, "Could not find code blob");
address ctable = cb->content_begin();

return *(address*)(ctable + destination_toc_offset());
Expand All @@ -414,6 +418,7 @@ int NativeCallTrampolineStub::destination_toc_offset() const {

void NativeCallTrampolineStub::set_destination(address new_destination) {
CodeBlob* cb = CodeCache::find_blob(addr_at(0));
assert(cb != NULL, "Could not find code blob");
address ctable = cb->content_begin();

*(address*)(ctable + destination_toc_offset()) = new_destination;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018 SAP SE. All rights reserved.
* Copyright (c) 2012, 2020 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -345,7 +345,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
// BugId 4454115: A read from a MappedByteBuffer can fault here if the
// underlying file has been truncated. Do not crash the VM in such a case.
CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
CompiledMethod* nm = cb->as_compiled_method_or_null();
CompiledMethod* nm = cb ? cb->as_compiled_method_or_null() : NULL;
bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
address next_pc = pc + 4;
Expand Down

0 comments on commit 4553fa0

Please sign in to comment.