JDK-8214226 : SA: Incorrect BCI and Line Number with jstack if the top frame is in the interpreter
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86
  • Submitted: 2018-11-22
  • Updated: 2020-04-23
  • Resolved: 2018-12-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12 JDK 13
12 b24Fixed 13Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
mail snippet from David Griffiths below
=======================================================

I have observed that if the top frame is in the interpreter it reports the BCI and line number incorrectly. This is because X86Frame.getInterpreterFrameBCI uses the value stored on the stack rather than the actual live value stored in R13.

I have a patch for this which lets LinuxAMD64JavaThreadPDAccess.getCurrentFrameGuess pass the R13 value to X86Frame so that the latter can then do:

  public int getInterpreterFrameBCI() {
    Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0);
    // If we are in the top level frame then R13 may have been set for us which contains
    // the BCP. 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 (r13 != null) {
        bcp = r13;
    }
    Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0);

and this fixes the problem.

==============================================
Comments
This bug fix introduced the "illegal bci" failures we've been seeing on linux: JDK-8231634 and JDK-8222499.
23-04-2020

This fix was never applied to bsd-amd64, windows-amd64, and linux-x86. That means sometimes these platforms will see the same issue of a stale BCI and line number. I think we can ignore linux-x86. For the other two platforms we just need to apply the LinuxAMD64JavaThreadPDAccess changes to both WindowsAMD64JavaThreadPDAccess and BSDAMD64JavaThreadPDAccess: if (guesser.getPC() == null) { return new X86Frame(guesser.getSP(), guesser.getFP()); + } else if (VM.getVM().getInterpreter().contains(guesser.getPC())) { + // pass the value of R13 which contains the bcp for the top level frame + Address bcp = context.getRegisterAsAddress(AMD64ThreadContext.R13); + return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC(), null, bcp); } else { return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); } I've created JDK-8243500 to address this.
23-04-2020