JDK-8213434 : Thread list contains newly allocated/born thread that can result fatal crash
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2018-11-06
  • Updated: 2018-11-15
  • Resolved: 2018-11-07
Related Reports
Duplicate :  
Description
This problem is exposed by runtime/InternalApi/ThreadCpuTimesDeadlock.java test with ShenandoahGC.

Thread list contains newly allocated/born thread, has yet made runnable, e.g. thread_id = 0. 

For this particular test, when it iterates through threads with ThreadTimesClosure, it may crash in pthread_getcpuclockid() call if the thread has thread_id = 0.



Comments
It is a duplication of JDK-8212207. Thanks, David.
07-11-2018

This is the same issue reported in JDK-8212207. There are two potential problems: new threads, and already terminated threads. For new threads there was a recent fix in JDK-8212173, but note that there is a handshake that newly created threads must follow to ensure sufficient self-initialization prior to being added to any "thread list". Do the GC threads follow that required protocol?
07-11-2018

Added debug message: diff -r ad1d74280503 src/hotspot/os/linux/os_linux.cpp --- a/src/hotspot/os/linux/os_linux.cpp Tue Nov 06 11:00:06 2018 -0500 +++ b/src/hotspot/os/linux/os_linux.cpp Tue Nov 06 14:53:35 2018 -0500 @@ -5524,6 +5524,13 @@ static jlong fast_cpu_time(Thread *thread) { clockid_t clockid; + +printf("fast_cpu_time for thread id = %d state: %d", (int)thread->osthread()->pthread_id(), (int)thread->osthread()->get_state()); +if (thread->is_Worker_thread()) { +printf(" worker: %s", ((WorkerThread*)thread)->name()); +} +printf("\n"); + int rc = os::Linux::pthread_getcpuclockid(thread->osthread()->pthread_id(), &clockid); if (rc == 0) { Print out: fast_cpu_time for thread id = -262965504 state: 2 worker: Safepoint Cleanup Thread#0 fast_cpu_time for thread id = -261908736 state: 2 worker: Shenandoah GC Threads#0 fast_cpu_time for thread id = -952690944 state: 4 fast_cpu_time for thread id = -953743616 state: 2 fast_cpu_time for thread id = -954796288 state: 2 fast_cpu_time for thread id = -955848960 state: 2 fast_cpu_time for thread id = -967608576 state: 2 fast_cpu_time for thread id = 0 state: 0 worker: Shenandoah GC Threads#1 <=== this is the offender Current thread is 25093
06-11-2018