JDK-8294920 : Missing SP value in Linux x86_32 thread context
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 11,17,19,20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-10-06
  • Updated: 2022-10-10
  • Resolved: 2022-10-07
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 20
20 masterFixed
Related Reports
Relates :  
Relates :  
Description
Manifests with recently added test on x86_32:

$ CONF=linux-x86-server-fastdebug make test TEST=serviceability/sa/ClhsdbThreadContext.java

...

Thread "SteadyStateThread" id=2303604 Address=0xa52d32e0
GS: 0x00000063
FS: null
ES: 0x0000002b
DS: 0x0000002b
EDI: null
ESI: 0xa3e7cb40: In java stack [0xa3e7e000,null,0xa3e2e000] for thread sun.jvm.hotspot.runtime.JavaThread@0xa52d32e0:
   "SteadyStateThread" #19 prio=5 tid=0xa52d32e0 nid=2303604 waiting for monitor entry [0xa3e7c000]
   java.lang.Thread.State: BLOCKED (on object monitor)
   JavaThread state: _thread_blocked
EBP: 0xffffffff
ESP: null
EBX: 0xa52d3a68
EDX: null
ECX: 0x00000089
EAX: 0xfffffdfc
TRAPNO: null
ERR: null
EIP: 0xf7f38549
CS: 0x00000023
EFLAGS: null
UESP: 0xa3e7cb08: In java stack [0xa3e7e000,null,0xa3e2e000] for thread sun.jvm.hotspot.runtime.JavaThread@0xa52d32e0:
   "SteadyStateThread" #19 prio=5 tid=0xa52d32e0 nid=2303604 waiting for monitor entry [0xa3e7c000]
   java.lang.Thread.State: BLOCKED (on object monitor)
   JavaThread state: _thread_blocked


java.lang.RuntimeException: Test ERROR java.lang.RuntimeException: 'In java stack \[0x\p{XDigit}+,0x\p{XDigit}+,0x\p{XDigit}+\] for thread' missing from stdout/stderr
```

The test fails because debugger output prints `null` in `[0xa3e7e000,null,0xa3e2e000]`, which is read from ESP. However, we actually populate only `SP`, which is the alias to `UESP`, *not* `ESP`, in `Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getThreadIntegerRegisterSet0`. See the snippet above: `UESP` is definitely there.

`UESP` is user stack pointer in Solaris, `sp_at_signal` in Linux. It looks to me from Linux sources that `sp_at_signal` is always populated with the same value as `sp`. So we either need to populate `ESP` from `get_lwp_regs` input, or we should pull from `SP` (which is aliased to `UESP`) in `*X86JavaThreadPDAccess.getLastSP()`. Prior work in JDK-8208091 did the latter.
Comments
Changeset: fe7a4617 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2022-10-07 18:23:16 +0000 URL: https://git.openjdk.org/jdk/commit/fe7a4617fec4d9358b8ce08d74f82714198867d1
07-10-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10598 Date: 2022-10-06 18:59:57 +0000
06-10-2022