JDK-8283467 : runtime/Thread/StopAtExit.java needs updating
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-03-21
  • Updated: 2022-04-14
  • Resolved: 2022-03-24
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 19
19 b16Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
Thread.stop(), ThreadGroup.destroy(), ThreadGroup.isDestroyed(),
ThreadGroup.setDaemon() are deprecated for removal:

----------direct:(19/1707)----------
/System/Volumes/Data/work/shared/bug_hunt/thread_SMR_stress/jdk19_exp.git/open/test/hotspot/jtreg/runtime/Thread/StopAtExit.java:91: warning: [removal] setDaemon(boolean) in ThreadGroup has been deprecated and marked for removal
            myTG.setDaemon(true);
                ^
/System/Volumes/Data/work/shared/bug_hunt/thread_SMR_stress/jdk19_exp.git/open/test/hotspot/jtreg/runtime/Thread/StopAtExit.java:101: warning: [removal] stop() in Thread has been deprecated and marked for removal
                    thread.stop();
                          ^
/System/Volumes/Data/work/shared/bug_hunt/thread_SMR_stress/jdk19_exp.git/open/test/hotspot/jtreg/runtime/Thread/StopAtExit.java:125: warning: [removal] stop() in Thread has been deprecated and marked for removal
            thread.stop();
                  ^
/System/Volumes/Data/work/shared/bug_hunt/thread_SMR_stress/jdk19_exp.git/open/test/hotspot/jtreg/runtime/Thread/StopAtExit.java:142: warning: [removal] isDestroyed() in ThreadGroup has been deprecated and marked for removal
                if (!myTG.isDestroyed()) {
                         ^
/System/Volumes/Data/work/shared/bug_hunt/thread_SMR_stress/jdk19_exp.git/open/test/hotspot/jtreg/runtime/Thread/StopAtExit.java:146: warning: [removal] isDestroyed() in ThreadGroup has been deprecated and marked for removal
            } else if (!myTG.isDestroyed()) {
                            ^
/System/Volumes/Data/work/shared/bug_hunt/thread_SMR_stress/jdk19_exp.git/open/test/hotspot/jtreg/runtime/Thread/StopAtExit.java:154: warning: [removal] destroy() in ThreadGroup has been deprecated and marked for removal
                    myTG.destroy();
                        ^
6 warnings
result: Passed. Compilation successful


Will be switching from java.lang.Thread.stop() to JVM/TI StopThread().
Will also be cleaning up the error handling since the JVM/TI APIs
actually return error codes. 

The java.lang.ThreadGroup.destroy(), ThreadGroup.isDestroyed(),
ThreadGroup.setDaemon() methods are used for cleaning up
memory leaks that can be caused by async exception delivery.
After the fix for:

    JDK-8282952 Thread::exit should be immune to Thread.stop

is integrated, the code that does that cleanup should not be
necessary. However, I may do cleanup as a separate RFE.
Comments
Changeset: a7e98834 Author: Daniel D. Daugherty <dcubed@openjdk.org> Date: 2022-03-24 17:06:35 +0000 URL: https://git.openjdk.java.net/jdk/commit/a7e988343c7fda5b0f37e477f29cb172b908394d
24-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7910 Date: 2022-03-22 18:52:20 +0000
22-03-2022

Switching from java.lang.Thread.stop() to JVM/TI StopThread() is very straight forward. Especially when following in the footsteps of the previous work done on runtimeThread/SuspendThreadAtExit.java and runtimeThread/libSuspendAtExit.cpp. Will do a 12 hour overnight stress run for the three configs: release, fastdebug and slowdebug.
21-03-2022

The JVM/TI StopThread() call is much more likely to run into: JDK-8282704 runtime/Thread/StopAtExit.java may leak memory Here's some snippets from 30 second runs on my MBP13: Release bits: About to execute for 30 seconds. Manually destroyed ThreadGroup 150896 times. Manually terminated Thread 221495 times. Executed 377227 loops in 30 seconds. Fastdebug bits: About to execute for 30 seconds. Manually destroyed ThreadGroup 36092 times. Manually terminated Thread 137 times. Executed 126888 loops in 30 seconds. Slowdebug bits: About to execute for 30 seconds. Manually destroyed ThreadGroup 983 times. Manually terminated Thread 42785 times. Executed 45381 loops in 30 seconds.
21-03-2022