diff --git a/src/hotspot/share/memory/guardedMemory.hpp b/src/hotspot/share/memory/guardedMemory.hpp index b40b1e8950d88..baced96a3f5a4 100644 --- a/src/hotspot/share/memory/guardedMemory.hpp +++ b/src/hotspot/share/memory/guardedMemory.hpp @@ -26,6 +26,7 @@ #define SHARE_MEMORY_GUARDEDMEMORY_HPP #include "memory/allocation.hpp" +#include "runtime/os.hpp" #include "runtime/safefetch.hpp" #include "utilities/globalDefinitions.hpp" @@ -113,14 +114,14 @@ class GuardedMemory : StackObj { // Wrapper on stack } bool verify() const { + // We may not be able to dereference directly. + if (!os::is_readable_range((const void*) _guard, (const void*) (_guard + GUARD_SIZE))) { + return false; + } u_char* c = (u_char*) _guard; u_char* end = c + GUARD_SIZE; while (c < end) { - // We may not be able to dereference directly so use - // SafeFetch. It doesn't matter if the value read happens - // to be 0xFF as that is not what we expect anyway. - u_char val = (u_char) SafeFetch32((int*)c, 0xFF); - if (val != badResourceValue) { + if (*c != badResourceValue) { return false; } c++;