JDK-8282952 : Thread::exit should be immune to Thread.stop
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-03-10
  • Updated: 2022-04-23
  • Resolved: 2022-03-23
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 b15Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Description
Thread::exit runs tear-down/cleanup code before a Thread terminates. It's impossible to reason about how this code might behave with an async exception. 

HotSpot has historically invoked the method up to 3 times or until the Thread.group field is null. That may have worked but this code will likely change significantly with loom. It's harder to reason about how the new code may behave with an async exception.

Thread.stop is terminally deprecated and will likely be degraded to throw UOE in a release or two. This removes it from the user facing API but async exceptions are still possible with the debugger APIs.

This issue tracks exploring if Thread::exit can be made immune to async exceptions. Maybe a new terminating state can be introduced so that sending an async exception does nothing when the thread is exiting.
Comments
Changeset: 8cc12350 Author: David Holmes <dholmes@openjdk.org> Date: 2022-03-23 00:06:53 +0000 URL: https://git.openjdk.java.net/jdk/commit/8cc12350294c202ae4050471587b95135a9f6ac6
23-03-2022

After this fix has had some bake time, I think we should considering backporting it to earlier releases.
21-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7886 Date: 2022-03-21 07:59:08 +0000
21-03-2022