Re: RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung" [v3]
> The debuggee main method creates two threads and then starts them: > > > public static void main(String[] args) { > System.out.println("Howdy!"); > Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); > Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); > > t1.start(); > t2.start(); > } > > > These threads will hit breakpoints which the debugger handles and issues an > invoke on the breakpoint thread. The threads run until they generate 100 > breakpoints. There is an issue when these two threads are virtual threads. > Virtual threads are daemon threads. That means the JVM can exit while they > are still running. The above main() method is not waiting for these two > threads to exit, so main() exits immediately and the JVM starts the shutdown > process. It first must wait for all non-daemon threads to exit, but there are > none, so the JVM exits right away before the two threads are completed. The > end result of this early exit is that sometimes the invoke done by the > debugger never completes because the JVM has already issued a VMDeath event > and the debuggee has been disconnected. > > When these two threads are platform threads, the JVM has to wait until they > complete before it exits, so they will always complete. The fix for virtual > threads is to do a join with t1 and t2. This forces the main() method to > block until they have completed. Chris Plummer has updated the pull request incrementally with one additional commit since the last revision: fix spelling error - Changes: - all: https://git.openjdk.org/jdk/pull/13068/files - new: https://git.openjdk.org/jdk/pull/13068/files/58ca27b8..87b32dc6 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk=13068=02 - incr: https://webrevs.openjdk.org/?repo=jdk=13068=01-02 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/13068.diff Fetch: git fetch https://git.openjdk.org/jdk pull/13068/head:pull/13068 PR: https://git.openjdk.org/jdk/pull/13068
Re: RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung" [v2]
On Sat, 18 Mar 2023 00:22:54 GMT, Chris Plummer wrote: >> The debuggee main method creates two threads and then starts them: >> >> >> public static void main(String[] args) { >> System.out.println("Howdy!"); >> Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); >> Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); >> >> t1.start(); >> t2.start(); >> } >> >> >> These threads will hit breakpoints which the debugger handles and issues an >> invoke on the breakpoint thread. The threads run until they generate 100 >> breakpoints. There is an issue when these two threads are virtual threads. >> Virtual threads are daemon threads. That means the JVM can exit while they >> are still running. The above main() method is not waiting for these two >> threads to exit, so main() exits immediately and the JVM starts the shutdown >> process. It first must wait for all non-daemon threads to exit, but there >> are none, so the JVM exits right away before the two threads are completed. >> The end result of this early exit is that sometimes the invoke done by the >> debugger never completes because the JVM has already issued a VMDeath event >> and the debuggee has been disconnected. >> >> When these two threads are platform threads, the JVM has to wait until they >> complete before it exits, so they will always complete. The fix for virtual >> threads is to do a join with t1 and t2. This forces the main() method to >> block until they have completed. > > Chris Plummer has updated the pull request incrementally with three > additional commits since the last revision: > > - fix spelling error > - add comment > - minor formatting fix Thumbs up. Thanks for adding the comment. One possible nit typo... test/jdk/com/sun/jdi/InvokeHangTest.java line 65: > 63: try { > 64: // The join ensures that the test completes before we exit > main(). If we are using > 65: // virtual threads, they are always daemon threads, and > therefor the JVM will exit nit typo: s/therefor/therefore/ - Marked as reviewed by dcubed (Reviewer). PR: https://git.openjdk.org/jdk/pull/13068
Re: RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung" [v2]
> The debuggee main method creates two threads and then starts them: > > > public static void main(String[] args) { > System.out.println("Howdy!"); > Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); > Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); > > t1.start(); > t2.start(); > } > > > These threads will hit breakpoints which the debugger handles and issues an > invoke on the breakpoint thread. The threads run until they generate 100 > breakpoints. There is an issue when these two threads are virtual threads. > Virtual threads are daemon threads. That means the JVM can exit while they > are still running. The above main() method is not waiting for these two > threads to exit, so main() exits immediately and the JVM starts the shutdown > process. It first must wait for all non-daemon threads to exit, but there are > none, so the JVM exits right away before the two threads are completed. The > end result of this early exit is that sometimes the invoke done by the > debugger never completes because the JVM has already issued a VMDeath event > and the debuggee has been disconnected. > > When these two threads are platform threads, the JVM has to wait until they > complete before it exits, so they will always complete. The fix for virtual > threads is to do a join with t1 and t2. This forces the main() method to > block until they have completed. Chris Plummer has updated the pull request incrementally with three additional commits since the last revision: - fix spelling error - add comment - minor formatting fix - Changes: - all: https://git.openjdk.org/jdk/pull/13068/files - new: https://git.openjdk.org/jdk/pull/13068/files/4d28b92e..58ca27b8 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk=13068=01 - incr: https://webrevs.openjdk.org/?repo=jdk=13068=00-01 Stats: 8 lines in 1 file changed: 6 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/13068.diff Fetch: git fetch https://git.openjdk.org/jdk pull/13068/head:pull/13068 PR: https://git.openjdk.org/jdk/pull/13068
Re: RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"
On Thu, 16 Mar 2023 21:02:09 GMT, Chris Plummer wrote: > The debuggee main method creates two threads and then starts them: > > > public static void main(String[] args) { > System.out.println("Howdy!"); > Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); > Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); > > t1.start(); > t2.start(); > } > > > These threads will hit breakpoints which the debugger handles and issues an > invoke on the breakpoint thread. The threads run until they generate 100 > breakpoints. There is an issue when these two threads are virtual threads. > Virtual threads are daemon threads. That means the JVM can exit while they > are still running. The above main() method is not waiting for these two > threads to exit, so main() exits immediately and the JVM starts the shutdown > process. It first must wait for all non-daemon threads to exit, but there are > none, so the JVM exits right away before the two threads are completed. The > end result of this early exit is that sometimes the invoke done by the > debugger never completes because the JVM has already issued a VMDeath event > and the debuggee has been disconnected. > > When these two threads are platform threads, the JVM has to wait until they > complete before it exits, so they will always complete. The fix for virtual > threads is to do a join with t1 and t2. This forces the main() method to > block until they have completed. Marked as reviewed by dcubed (Reviewer). test/jdk/com/sun/jdi/InvokeHangTest.java line 67: > 65: } catch (InterruptedException e) { > 66: throw new RuntimeException(e); > 67: } Please consider adding a comment that explains that the `join()` calls are only necessary when `t1` and `t2` are virtual threads. - PR: https://git.openjdk.org/jdk/pull/13068
Re: RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"
On Thu, 16 Mar 2023 21:02:09 GMT, Chris Plummer wrote: > The debuggee main method creates two threads and then starts them: > > > public static void main(String[] args) { > System.out.println("Howdy!"); > Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); > Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); > > t1.start(); > t2.start(); > } > > > These threads will hit breakpoints which the debugger handles and issues an > invoke on the breakpoint thread. The threads run until they generate 100 > breakpoints. There is an issue when these two threads are virtual threads. > Virtual threads are daemon threads. That means the JVM can exit while they > are still running. The above main() method is not waiting for these two > threads to exit, so main() exits immediately and the JVM starts the shutdown > process. It first must wait for all non-daemon threads to exit, but there are > none, so the JVM exits right away before the two threads are completed. The > end result of this early exit is that sometimes the invoke done by the > debugger never completes because the JVM has already issued a VMDeath event > and the debuggee has been disconnected. > > When these two threads are platform threads, the JVM has to wait until they > complete before it exits, so they will always complete. The fix for virtual > threads is to do a join with t1 and t2. This forces the main() method to > block until they have completed. Looks good. Thanks, Serguei - Marked as reviewed by sspitsyn (Reviewer). PR: https://git.openjdk.org/jdk/pull/13068
Re: RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"
On Thu, 16 Mar 2023 21:02:09 GMT, Chris Plummer wrote: > The debuggee main method creates two threads and then starts them: > > > public static void main(String[] args) { > System.out.println("Howdy!"); > Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); > Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); > > t1.start(); > t2.start(); > } > > > These threads will hit breakpoints which the debugger handles and issues an > invoke on the breakpoint thread. The threads run until they generate 100 > breakpoints. There is an issue when these two threads are virtual threads. > Virtual threads are daemon threads. That means the JVM can exit while they > are still running. The above main() method is not waiting for these two > threads to exit, so main() exits immediately and the JVM starts the shutdown > process. It first must wait for all non-daemon threads to exit, but there are > none, so the JVM exits right away before the two threads are completed. The > end result of this early exit is that sometimes the invoke done by the > debugger never completes because the JVM has already issued a VMDeath event > and the debuggee has been disconnected. > > When these two threads are platform threads, the JVM has to wait until they > complete before it exits, so they will always complete. The fix for virtual > threads is to do a join with t1 and t2. This forces the main() method to > block until they have completed. Marked as reviewed by lmesnik (Reviewer). - PR: https://git.openjdk.org/jdk/pull/13068
Re: RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"
On Thu, 16 Mar 2023 21:02:09 GMT, Chris Plummer wrote: > The debuggee main method creates two threads and then starts them: > > > public static void main(String[] args) { > System.out.println("Howdy!"); > Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); > Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); > > t1.start(); > t2.start(); > } > > > These threads will hit breakpoints which the debugger handles and issues an > invoke on the breakpoint thread. The threads run until they generate 100 > breakpoints. There is an issue when these two threads are virtual threads. > Virtual threads are daemon threads. That means the JVM can exit while they > are still running. The above main() method is not waiting for these two > threads to exit, so main() exits immediately and the JVM starts the shutdown > process. It first must wait for all non-daemon threads to exit, but there are > none, so the JVM exits right away before the two threads are completed. The > end result of this early exit is that sometimes the invoke done by the > debugger never completes because the JVM has already issued a VMDeath event > and the debuggee has been disconnected. > > When these two threads are platform threads, the JVM has to wait until they > complete before it exits, so they will always complete. The fix for virtual > threads is to do a join with t1 and t2. This forces the main() method to > block until they have completed. Marked as reviewed by amenkov (Reviewer). test/jdk/com/sun/jdi/InvokeHangTest.java line 200: > 198: try { > 199: StackFrame sf = thread.frame(0); > 200: System.out.println(" Debugger: Breakpoint hit at > "+sf.location()); while you are here please add spaces around plus - PR: https://git.openjdk.org/jdk/pull/13068
Re: RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"
On Thu, 16 Mar 2023 21:02:09 GMT, Chris Plummer wrote: > The debuggee main method creates two threads and then starts them: > > > public static void main(String[] args) { > System.out.println("Howdy!"); > Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); > Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); > > t1.start(); > t2.start(); > } > > > These threads will hit breakpoints which the debugger handles and issues an > invoke on the breakpoint thread. The threads run until they generate 100 > breakpoints. There is an issue when these two threads are virtual threads. > Virtual threads are daemon threads. That means the JVM can exit while they > are still running. The above main() method is not waiting for these two > threads to exit, so main() exits immediately and the JVM starts the shutdown > process. It first must wait for all non-daemon threads to exit, but there are > none, so the JVM exits right away before the two threads are completed. The > end result of this early exit is that sometimes the invoke done by the > debugger never completes because the JVM has already issued a VMDeath event > and the debuggee has been disconnected. > > When these two threads are platform threads, the JVM has to wait until they > complete before it exits, so they will always complete. The fix for virtual > threads is to do a join with t1 and t2. This forces the main() method to > block until they have completed. test/jdk/com/sun/jdi/InvokeHangTest.java line 223: > 221: mainThread = bpe.thread(); > 222: EventRequestManager erm = vm().eventRequestManager(); > 223: final Thread mainTestThread = Thread.currentThread(); This local variable was conflicting with an instance field of the same name. See line 135. I ran into issues when I added some debugging code to this method that referenced the other `mainThread`, so I did a rename. - PR: https://git.openjdk.org/jdk/pull/13068
RFR: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"
The debuggee main method creates two threads and then starts them: public static void main(String[] args) { System.out.println("Howdy!"); Thread t1 = TestScaffold.newThread(new InvokeHangTarg(), name1); Thread t2 = TestScaffold.newThread(new InvokeHangTarg(), name2); t1.start(); t2.start(); } These threads will hit breakpoints which the debugger handles and issues an invoke on the breakpoint thread. The threads run until they generate 100 breakpoints. There is an issue when these two threads are virtual threads. Virtual threads are daemon threads. That means the JVM can exit while they are still running. The above main() method is not waiting for these two threads to exit, so main() exits immediately and the JVM starts the shutdown process. It first must wait for all non-daemon threads to exit, but there are none, so the JVM exits right away before the two threads are completed. The end result of this early exit is that sometimes the invoke done by the debugger never completes because the JVM has already issued a VMDeath event and the debuggee has been disconnected. When these two threads are platform threads, the JVM has to wait until they complete before it exits, so they will always complete. The fix for virtual threads is to do a join with t1 and t2. This forces the main() method to block until they have completed. - Commit messages: - Make sure main() debuggee method does not exit until test threads are complete. Changes: https://git.openjdk.org/jdk/pull/13068/files Webrev: https://webrevs.openjdk.org/?repo=jdk=13068=00 Issue: https://bugs.openjdk.org/browse/JDK-8290200 Stats: 13 lines in 2 files changed: 6 ins; 2 del; 5 mod Patch: https://git.openjdk.org/jdk/pull/13068.diff Fetch: git fetch https://git.openjdk.org/jdk pull/13068/head:pull/13068 PR: https://git.openjdk.org/jdk/pull/13068