< prev index next >
src/hotspot/share/code/codeHeapState.cpp
Print this page
rev 51015 : 8207342: error occurred during error reporting (printing register info)
Summary: os::print_location misses a check if the pointer is readable.
Reviewed-by:
*** 2104,2115 ****
// heap->find_start() is safe. Only working with _segmap. Returns NULL or void*. Returned CodeBlob may be uninitialized.
CodeBlob* this_blob = (CodeBlob *)(heap->find_start(low_bound+ix*granule_size+is));
bool blob_initialized = (this_blob != NULL) && (this_blob->header_size() >= 0) && (this_blob->relocation_size() >= 0) &&
((address)this_blob + this_blob->header_size() == (address)(this_blob->relocation_begin())) &&
((address)this_blob + CodeBlob::align_code_offset(this_blob->header_size() + this_blob->relocation_size()) == (address)(this_blob->content_begin())) &&
! is_readable_pointer((address)(this_blob->relocation_begin())) &&
! is_readable_pointer(this_blob->content_begin());
// blob could have been flushed, freed, and merged.
// this_blob < last_blob is an indicator for that.
if (blob_initialized && (this_blob > last_blob)) {
last_blob = this_blob;
--- 2104,2115 ----
// heap->find_start() is safe. Only working with _segmap. Returns NULL or void*. Returned CodeBlob may be uninitialized.
CodeBlob* this_blob = (CodeBlob *)(heap->find_start(low_bound+ix*granule_size+is));
bool blob_initialized = (this_blob != NULL) && (this_blob->header_size() >= 0) && (this_blob->relocation_size() >= 0) &&
((address)this_blob + this_blob->header_size() == (address)(this_blob->relocation_begin())) &&
((address)this_blob + CodeBlob::align_code_offset(this_blob->header_size() + this_blob->relocation_size()) == (address)(this_blob->content_begin())) &&
! os::is_readable_pointer((address)(this_blob->relocation_begin())) &&
! os::is_readable_pointer(this_blob->content_begin());
// blob could have been flushed, freed, and merged.
// this_blob < last_blob is an indicator for that.
if (blob_initialized && (this_blob > last_blob)) {
last_blob = this_blob;
*** 2120,2130 ****
} else {
cbType = get_cbType(this_blob);
}
// this_blob->name() could return NULL if no name was given to CTOR. Inlined, maybe invisible on stack
const char* blob_name = this_blob->name();
! if ((blob_name == NULL) || !is_readable_pointer(blob_name)) {
blob_name = "<unavailable>";
}
//---< print table header for new print range >---
if (!name_in_addr_range) {
--- 2120,2130 ----
} else {
cbType = get_cbType(this_blob);
}
// this_blob->name() could return NULL if no name was given to CTOR. Inlined, maybe invisible on stack
const char* blob_name = this_blob->name();
! if ((blob_name == NULL) || !os::is_readable_pointer(blob_name)) {
blob_name = "<unavailable>";
}
//---< print table header for new print range >---
if (!name_in_addr_range) {
*** 2145,2155 ****
// this_blob->as_nmethod_or_null() is safe. Inlined, maybe invisible on stack.
nmethod* nm = this_blob->as_nmethod_or_null();
Method* method = (nm == NULL) ? NULL : nm->method(); // may be uninitialized, i.e. != NULL, but invalid
if ((nm != NULL) && (method != NULL) && (cbType != nMethod_dead) &&
! is_readable_pointer(method) && is_readable_pointer(method->constants())) {
ResourceMark rm;
//---< collect all data to locals as quickly as possible >---
unsigned int total_size = nm->total_size();
int hotness = nm->hotness_counter();
bool get_name = (cbType == nMethod_inuse) || (cbType == nMethod_notused);
--- 2145,2155 ----
// this_blob->as_nmethod_or_null() is safe. Inlined, maybe invisible on stack.
nmethod* nm = this_blob->as_nmethod_or_null();
Method* method = (nm == NULL) ? NULL : nm->method(); // may be uninitialized, i.e. != NULL, but invalid
if ((nm != NULL) && (method != NULL) && (cbType != nMethod_dead) &&
! os::is_readable_pointer(method) && os::is_readable_pointer(method->constants())) {
ResourceMark rm;
//---< collect all data to locals as quickly as possible >---
unsigned int total_size = nm->total_size();
int hotness = nm->hotness_counter();
bool get_name = (cbType == nMethod_inuse) || (cbType == nMethod_notused);
*** 2344,2354 ****
ast->print("(+" PTR32_FORMAT "): |", (unsigned int)(ix*granule_size));
}
}
CodeHeapState::blobType CodeHeapState::get_cbType(CodeBlob* cb) {
! if ((cb != NULL) && is_readable_pointer(cb)) {
if (cb->is_runtime_stub()) return runtimeStub;
if (cb->is_deoptimization_stub()) return deoptimizationStub;
if (cb->is_uncommon_trap_stub()) return uncommonTrapStub;
if (cb->is_exception_stub()) return exceptionStub;
if (cb->is_safepoint_stub()) return safepointStub;
--- 2344,2354 ----
ast->print("(+" PTR32_FORMAT "): |", (unsigned int)(ix*granule_size));
}
}
CodeHeapState::blobType CodeHeapState::get_cbType(CodeBlob* cb) {
! if ((cb != NULL) && os::is_readable_pointer(cb)) {
if (cb->is_runtime_stub()) return runtimeStub;
if (cb->is_deoptimization_stub()) return deoptimizationStub;
if (cb->is_uncommon_trap_stub()) return uncommonTrapStub;
if (cb->is_exception_stub()) return exceptionStub;
if (cb->is_safepoint_stub()) return safepointStub;
*** 2366,2384 ****
return nMethod_dead;
}
}
return noType;
}
-
- // Check if pointer can be read from (4-byte read access).
- // Helps to prove validity of a not-NULL pointer.
- // Returns true in very early stages of VM life when stub is not yet generated.
- #define SAFEFETCH_DEFAULT true
- bool CodeHeapState::is_readable_pointer(const void* p) {
- if (!CanUseSafeFetch32()) {
- return SAFEFETCH_DEFAULT;
- }
- int* const aligned = (int*) align_down((intptr_t)p, 4);
- int cafebabe = 0xcafebabe; // tester value 1
- int deadbeef = 0xdeadbeef; // tester value 2
- return (SafeFetch32(aligned, cafebabe) != cafebabe) || (SafeFetch32(aligned, deadbeef) != deadbeef);
- }
--- 2366,2370 ----
< prev index next >