RFR: 8335743: jhsdb jstack cannot print some information on the waiting thread
David Holmes
dholmes at openjdk.org
Mon Jul 8 06:56:32 UTC 2024
On Fri, 5 Jul 2024 09:23:21 GMT, KIRIYAMA Takuya <duke at openjdk.org> wrote:
> This bug was introduced by JDK-8284161. "Object.wait (long timeoutMillis)" was changed to call "Object.wait0 (long timeoutMillis)" in JDK-8284161.
>
> When "jhdsb jstack" is executed, the stack and lock information are printed in "sun.jvm.hotspot.runtime.JavaVFrame.printLockInfo(PrintStream tty, int frameCount)". This method checks whether the method is java.lang.Object.wait (...) and then reports the waitstate only if the check passes.
> https://github.com/openjdk/jdk/blob/7bc8f9c150cbf457edf6144adba734ecd5ca5a0f/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JavaVFrame.java#L103
>
>
> if (getMethod().getName().asString().equals("wait") &&
> getMethod().getMethodHolder().getName().asString().equals("java/lang/Object")) {
>
>
> However, after JDK-8284161, the waiting thread waits on "java.lang.Object.wait0 (long timeoutMillis)", so it no longer reports the waitstate.
>
> I changed "printLockInfo(PrintStream tty, int frameCount)" to check for "java.lang.Object.wait0 (...)".
> I confirmed that the lock information is correctly printed with this fix.
> I tested hotspot/jtreg/serviceability/sa/ and jdk/sun/tools/jhsdb/heapconfig/, and there were no regressions by this fix.
>
> Would anyone review this change, please?
Good catch on the underlying issue. I think the test needs an adjustment though.
Thanks
test/hotspot/jtreg/serviceability/sa/LingeredAppWithLock.java line 54:
> 52: Thread objectLock = new Thread(() -> lockMethod(classLock1));
> 53: Thread primitiveLock = new Thread(() -> lockMethod(int.class));
> 54: Thread objectWait = new Thread(() -> waitMethod(new Object()));
Use of `new Object()` could be problematic here as the JIT can recognise that this is a non-escaping object and elide the synchronization.
-------------
Changes requested by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/20049#pullrequestreview-2162420583
PR Review Comment: https://git.openjdk.org/jdk/pull/20049#discussion_r1668084668
More information about the serviceability-dev
mailing list