OpenJDK / jdk / jdk
changeset 59051:1d09feee810c
8231634: SA stack walking fails with "illegal bci"
Reviewed-by: amenkov, sspitsyn
author | cjplummer |
---|---|
date | Tue, 28 Apr 2020 13:35:46 -0700 |
parents | 51a1b5201cd5 |
children | 06745527c7b8 |
files | src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstMethod.java src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadStackTrace.java src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java test/jdk/ProblemList.txt |
diffstat | 4 files changed, 29 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstMethod.java Tue Apr 28 17:31:20 2020 +0000 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstMethod.java Tue Apr 28 13:35:46 2020 -0700 @@ -194,6 +194,17 @@ // bytecode accessors + /** See if address is in the Method's bytecodes */ + public boolean isAddressInMethod(Address bcp) { + Address bytecodeStart = getAddress().addOffsetTo(bytecodeOffset); + Address bytecodeEnd = bytecodeStart.addOffsetTo(getCodeSize() - 1); + if (bcp.greaterThanOrEqual(bytecodeStart) && bcp.lessThanOrEqual(bytecodeEnd)) { + return true; + } else { + return false; + } + } + /** Get a bytecode or breakpoint at the given bci */ public int getBytecodeOrBPAt(int bci) { return getAddress().getJByteAt(bytecodeOffset + bci) & 0xFF; @@ -296,7 +307,8 @@ } if (Assert.ASSERTS_ENABLED) { - Assert.that(bci == 0 || 0 <= bci && bci < getCodeSize(), "illegal bci"); + Assert.that(0 <= bci && bci < getCodeSize(), + "illegal bci(" + bci + ") codeSize(" + getCodeSize() + ")"); } int bestBCI = 0; int bestLine = -1;
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadStackTrace.java Tue Apr 28 17:31:20 2020 +0000 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadStackTrace.java Tue Apr 28 13:35:46 2020 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ public void dumpStack(int maxDepth) { if (!thread.isJavaThread()) { - System.out.println("dumpStack: not java Thread returning"); + System.out.println("dumpStack: not java Thread."); return; } try {
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java Tue Apr 28 17:31:20 2020 +0000 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java Tue Apr 28 13:35:46 2020 -0700 @@ -444,17 +444,23 @@ // FIXME: this is not atomic with respect to GC and is unsuitable // for use in a non-debugging, or reflective, system. Need to // figure out how to express this. - Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0); - - // If we are in the top level frame then the bcp may have been set for us. If so then let it - // take priority. If we are in a top level interpreter frame, the bcp is live in R13 (on x86) - // and not saved in the BCX stack slot. - if (live_bcp != null) { - bcp = live_bcp; - } Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0); Method method = (Method)Metadata.instantiateWrapperFor(methodHandle); + Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0); + + // If we are in the top level frame then the bcp may have been set for us. If so then let it + // take priority. If we are in a top level interpreter frame, the bcp is live in R13 (on x86_64) + // and not saved in the BCX stack slot. + if (live_bcp != null) { + // Only use live_bcp if it points within the Method's bytecodes. Sometimes R13 is used + // for scratch purposes and is not a valid BCP. If it is not valid, then we stick with + // the bcp stored in the frame, which R13 should have been flushed to. + if (method.getConstMethod().isAddressInMethod(live_bcp)) { + bcp = live_bcp; + } + } + return bcpToBci(bcp, method); }
--- a/test/jdk/ProblemList.txt Tue Apr 28 17:31:20 2020 +0000 +++ b/test/jdk/ProblemList.txt Tue Apr 28 13:35:46 2020 -0700 @@ -937,7 +937,6 @@ # svc_tools sun/tools/jhsdb/BasicLauncherTest.java 8211767 linux-ppc64,linux-ppc64le -sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java 8231634 generic-all ############################################################################