8219459: oopDesc::is_valid() is broken
Use Metaspace::contains() to test address ranges. Reviewed-by: mdoerr, stuefe, jiangli
This commit is contained in:
parent
64b8734964
commit
2a48a29c33
@ -47,6 +47,7 @@
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/formatBuffer.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/vmError.hpp"
|
||||
|
||||
|
||||
using namespace metaspace;
|
||||
@ -917,31 +918,6 @@ void MetaspaceUtils::verify_metrics() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Utils to check if a pointer or range is part of a committed metaspace region.
|
||||
metaspace::VirtualSpaceNode* MetaspaceUtils::find_enclosing_virtual_space(const void* p) {
|
||||
MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
|
||||
VirtualSpaceNode* vsn = Metaspace::space_list()->find_enclosing_space(p);
|
||||
if (Metaspace::using_class_space() && vsn == NULL) {
|
||||
vsn = Metaspace::class_space_list()->find_enclosing_space(p);
|
||||
}
|
||||
return vsn;
|
||||
}
|
||||
|
||||
bool MetaspaceUtils::is_range_in_committed(const void* from, const void* to) {
|
||||
#if INCLUDE_CDS
|
||||
if (UseSharedSpaces) {
|
||||
for (int idx = MetaspaceShared::ro; idx <= MetaspaceShared::mc; idx++) {
|
||||
if (FileMapInfo::current_info()->is_in_shared_region(from, idx)) {
|
||||
return FileMapInfo::current_info()->is_in_shared_region(to, idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
VirtualSpaceNode* vsn = find_enclosing_virtual_space(from);
|
||||
return (vsn != NULL) && vsn->contains(to);
|
||||
}
|
||||
|
||||
|
||||
// Metaspace methods
|
||||
|
||||
size_t Metaspace::_first_chunk_word_size = 0;
|
||||
|
@ -329,11 +329,6 @@ class MetaspaceUtils : AllStatic {
|
||||
// Helper for print_xx_report.
|
||||
static void print_vs(outputStream* out, size_t scale);
|
||||
|
||||
// Utils to check if a pointer or range is part of a committed metaspace region
|
||||
// without acquiring any locks.
|
||||
static metaspace::VirtualSpaceNode* find_enclosing_virtual_space(const void* p);
|
||||
static bool is_range_in_committed(const void* from, const void* to);
|
||||
|
||||
public:
|
||||
|
||||
// Collect used metaspace statistics. This involves walking the CLDG. The resulting
|
||||
|
@ -813,7 +813,7 @@ bool Klass::is_valid(Klass* k) {
|
||||
if ((size_t)k < os::min_page_size()) return false;
|
||||
|
||||
if (!os::is_readable_range(k, k + 1)) return false;
|
||||
if (!MetaspaceUtils::is_range_in_committed(k, k + 1)) return false;
|
||||
if (!Metaspace::contains(k)) return false;
|
||||
|
||||
if (!Symbol::is_valid(k->name())) return false;
|
||||
return ClassLoaderDataGraph::is_valid(k->class_loader_data());
|
||||
|
@ -182,9 +182,7 @@ bool oopDesc::is_valid(oop obj) {
|
||||
if (!Universe::heap()->is_in(obj)) return false;
|
||||
|
||||
Klass* k = (Klass*)load_klass_raw(obj);
|
||||
|
||||
if (!os::is_readable_range(k, k + 1)) return false;
|
||||
return MetaspaceUtils::is_range_in_committed(k, k + 1);
|
||||
return Klass::is_valid(k);
|
||||
}
|
||||
|
||||
oop oopDesc::oop_or_null(address addr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user