JDK-8283010 : serviceability/sa/ClhsdbThread.java failed with "'Base of Stack:' missing from stdout/stderr "
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • CPU: x86_64
  • Submitted: 2022-03-11
  • Updated: 2022-09-12
  • Resolved: 2022-09-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 :  
Relates :  
Description
I saw the following failure with ClhsdbThread.java once on Windows:

java.lang.RuntimeException: Test ERROR java.lang.RuntimeException: 'Base of Stack:' missing from stdout/stderr 

	at ClhsdbThread.main(ClhsdbThread.java:108)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:1480)
Caused by: java.lang.RuntimeException: 'Base of Stack:' missing from stdout/stderr 
	at jdk.test.lib.process.OutputAnalyzer.shouldMatch(OutputAnalyzer.java:340)
	at ClhsdbLauncher.runCmd(ClhsdbLauncher.java:166)
	at ClhsdbLauncher.run(ClhsdbLauncher.java:203)
	at ClhsdbThread.main(ClhsdbThread.java:104)
	... 4 more

In the log you also see:

...
18 Finalizer
State: BLOCKED
Stack in use by Java: 0x000000864f1ff0d0 .. 0x000000864f1ff300
Base of Stack: 0x000000864f200000
Last_Java_SP: 0x000000864f1ff0d0
Last_Java_FP: null
Last_Java_PC: 0x000001bce09683e3
...
Thread Id obtained is: 18
...
hsdb> + thread 18
Couldn't find thread thread

The test finds the above "Finalizer" thread output, gleans the threadId from it, and then attempts to use the thread command on that threadId, but there is no longer a thread with that threadId.

This appears to be the same issue as JDK-8280770. Basically each time you attach to a target JVM, thread Id's can change. There is some explanation as to why this can happen in the CR:

https://bugs.openjdk.java.net/browse/JDK-8280770?focusedCommentId=14472814&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14472814

And also some discussion in the PR:

https://github.com/openjdk/jdk/pull/7259#issuecomment-1024508580

So bottom line is that you cannot reliable glean usable threadIds from a previous clhsdb shell session in this manner. The fix for JDK-8280770 was to just accept that on Windows you it might not work, so the output is no longer checked. We can do the same for this test.
Comments
Changeset: 51de7658 Author: Chris Plummer <cjplummer@openjdk.org> Date: 2022-09-07 21:51:46 +0000 URL: https://git.openjdk.org/jdk/commit/51de765867d4d44fc2e2953a0296ca6804135d89
07-09-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10185 Date: 2022-09-06 19:26:09 +0000
06-09-2022

For JDK-8283578 I'm working on a solution to this general testing issue of relaunching clhsdb for each clhsdb sub-command we want to execute. The issue in this CR would be resolved if we only launched clhsdb once, and sent multiple commands to it. The tricky part is getting the output after each command so the next command can be formed. This is what I'm hoping to accomplish with the fix for JDK-8283578. If successful, the same technique can be applied to this CR.
26-04-2022

When fixing this bug, it would be nice to also fix the following bug in the error output: hsdb> + thread 18 Couldn't find thread thread The code looks like: out.println("Couldn't find thread " + name); "name" is the name of the command. It should instead be "id".
11-03-2022