From 539c80bfda7eb8b8ffdb0c1bff58ac226d4bb236 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Sun, 21 Feb 2021 18:59:02 +0000 Subject: [PATCH] 8261702: ClhsdbFindPC can fail due to PointerFinder incorrectly thinking an address is in a .so Reviewed-by: ysuenaga, kevinw, sspitsyn --- .../jvm/hotspot/utilities/PointerFinder.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java index d34d0f4e908..90572eefb79 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java @@ -82,17 +82,6 @@ public class PointerFinder { } } - // Check if address is a native (C++) symbol - JVMDebugger dbg = VM.getVM().getDebugger(); - CDebugger cdbg = dbg.getCDebugger(); - if (cdbg != null) { - loc.loadObject = cdbg.loadObjectContainingPC(a); - if (loc.loadObject != null) { - loc.nativeSymbol = loc.loadObject.closestSymbolToPC(a); - return loc; - } - } - // Check if address is in the java heap. CollectedHeap heap = VM.getVM().getUniverse().heap(); if (heap instanceof GenCollectedHeap) { @@ -198,6 +187,19 @@ public class PointerFinder { } } + // Check if address is a native (C++) symbol. Do this last because we don't always + // do a good job of computing if an address is actually within a native lib, and sometimes + // an address outside of a lib will be found as inside. + JVMDebugger dbg = VM.getVM().getDebugger(); + CDebugger cdbg = dbg.getCDebugger(); + if (cdbg != null) { + loc.loadObject = cdbg.loadObjectContainingPC(a); + if (loc.loadObject != null) { + loc.nativeSymbol = loc.loadObject.closestSymbolToPC(a); + return loc; + } + } + // Fall through; have to return it anyway. return loc; }