--- old/src/hotspot/share/memory/filemap.cpp 2018-01-15 16:24:05.972485217 -0800 +++ new/src/hotspot/share/memory/filemap.cpp 2018-01-15 16:24:05.544469003 -0800 @@ -659,7 +659,7 @@ static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "OptionalData", "String1", "String2", "OpenArchive1", "OpenArchive2" }; -char* FileMapInfo::map_region(int i) { +char* FileMapInfo::map_region(int i, char** top_ret) { assert(!MetaspaceShared::is_heap_region(i), "sanity"); struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i]; size_t used = si->_used; @@ -686,6 +686,12 @@ MemTracker::record_virtual_memory_type((address)base, mtClassShared); #endif + + if (!verify_region_checksum(i)) { + return NULL; + } + + *top_ret = base + size; return base; } @@ -1040,27 +1046,6 @@ return status; } -// The following method is provided to see whether a given pointer -// falls in the mapped shared metadata space. -// Param: -// p, The given pointer -// Return: -// True if the p is within the mapped shared space, otherwise, false. -bool FileMapInfo::is_in_shared_space(const void* p) { - for (int i = 0; i < MetaspaceShared::num_non_heap_spaces; i++) { - char *base; - if (_header->_space[i]._used == 0) { - continue; - } - base = _header->region_addr(i); - if (p >= base && p < base + _header->_space[i]._used) { - return true; - } - } - - return false; -} - // Check if a given address is within one of the shared regions bool FileMapInfo::is_in_shared_region(const void* p, int idx) { assert(idx == MetaspaceShared::ro ||