8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block
authorstefank
Mon, 01 Apr 2019 18:36:01 +0200
changeset 54363 f60c52198a42
parent 54362 313e034d0bcb
child 54364 baf213e62aeb
8221149: os::malloc checks MallocCatchPtr outside of ifdef ASSERT block Reviewed-by: stuefe, dholmes
src/hotspot/share/runtime/os.cpp
--- a/src/hotspot/share/runtime/os.cpp	Mon Apr 01 18:34:47 2019 +0200
+++ b/src/hotspot/share/runtime/os.cpp	Mon Apr 01 18:36:01 2019 +0200
@@ -704,12 +704,15 @@
   // Wrap memory with guard
   GuardedMemory guarded(ptr, size + nmt_header_size);
   ptr = guarded.get_user_ptr();
-#endif
+
   if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) {
     log_warning(malloc, free)("os::malloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, p2i(ptr));
     breakpoint();
   }
-  debug_only(if (paranoid) verify_memory(ptr));
+  if (paranoid) {
+    verify_memory(ptr);
+  }
+#endif
 
   // we do not track guard memory
   return MemTracker::record_malloc((address)ptr, size, memflags, stack, level);
@@ -760,10 +763,8 @@
     // Guard's user data contains NMT header
     size_t memblock_size = guarded.get_user_size() - MemTracker::malloc_header_size(memblock);
     memcpy(ptr, memblock, MIN2(size, memblock_size));
-    if (paranoid) verify_memory(MemTracker::malloc_base(ptr));
-    if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) {
-      log_warning(malloc, free)("os::realloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, p2i(ptr));
-      breakpoint();
+    if (paranoid) {
+      verify_memory(MemTracker::malloc_base(ptr));
     }
     os::free(memblock);
   }