Skip to content

Commit 4553fa0

Browse files
committed
8256258: some missing NULL checks or asserts after CodeCache::find_blob_unsafe
Reviewed-by: shade
1 parent 1228517 commit 4553fa0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/hotspot/cpu/ppc/nativeInst_ppc.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2019 SAP SE. All rights reserved.
3+
* Copyright (c) 2012, 2020 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -177,6 +177,7 @@ void NativeFarCall::verify() {
177177
address NativeMovConstReg::next_instruction_address() const {
178178
#ifdef ASSERT
179179
CodeBlob* nm = CodeCache::find_blob(instruction_address());
180+
assert(nm != NULL, "Could not find code blob");
180181
assert(!MacroAssembler::is_set_narrow_oop(addr_at(0), nm->content_begin()), "Should not patch narrow oop here");
181182
#endif
182183

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

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

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

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

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

419424
*(address*)(ctable + destination_toc_offset()) = new_destination;

src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2018 SAP SE. All rights reserved.
3+
* Copyright (c) 2012, 2020 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -345,7 +345,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
345345
// BugId 4454115: A read from a MappedByteBuffer can fault here if the
346346
// underlying file has been truncated. Do not crash the VM in such a case.
347347
CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
348-
CompiledMethod* nm = cb->as_compiled_method_or_null();
348+
CompiledMethod* nm = cb ? cb->as_compiled_method_or_null() : NULL;
349349
bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
350350
if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
351351
address next_pc = pc + 4;

0 commit comments

Comments
 (0)