JDK-8361103 : java_lang_Thread::async_get_stack_trace does not properly protect JavaThread
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2025-06-30
  • Updated: 2025-08-19
  • Resolved: 2025-08-13
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 26
26 b11Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
src/hotspot/share/runtime/threadSMR.hpp has an example of the correct usage of ThreadsListHandle to protect JavaThread:
//   ThreadsListHandle tlh;
//   JavaThread* jt = nullptr;
//   bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &jt, nullptr);
//   if (is_alive) {
//     :  // do stuff with 'jt'...
//   }

java_lang_Thread::async_get_stack_trace() does not follow the pattern, but does:
JNIHandles::resolve(jthread) (in JVM_GetStackTrace)
ThreadsListHandle tlh(JavaThread::current());
JavaThread* thread = java_lang_Thread::thread(java_thread);
Comments
Changeset: ecbdd340 Branch: master Author: Alex Menkov <amenkov@openjdk.org> Date: 2025-08-13 18:24:56 +0000 URL: https://git.openjdk.org/jdk/commit/ecbdd3405a1d46f555deb82098e1865b44601a1f
13-08-2025

This code came in with the initial virtual threads preview in JDK-8284161
08-07-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/26119 Date: 2025-07-03 19:53:44 +0000
03-07-2025