OpenJDK 11 crash in pthread_getcpuclockid invoking jstack

Solution Unverified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL) 7.4
  • OpenJDK
    • 11.0.5
    • 11.0.7

Issue

  • In an Eclipse based product, jstack is run programmatically when automated regression tests hang. OpenJDK 11 occasionally crashes on the jstack invocation with the following stack in the fatal error log:
Stack: [0x00007fffb70a4000,0x00007fffb71a4000],  sp=0x00007fffb71a28f8,  free space=1018k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libpthread.so.0+0xce90]  pthread_getcpuclockid+0x0
V  [libjvm.so+0xe8a751]  Thread::print_on(outputStream*, bool) const+0x51
V  [libjvm.so+0xe8cfc6]  JavaThread::print_on(outputStream*, bool) const+0xe6
V  [libjvm.so+0xe8fd18]  Threads::print_on(outputStream*, bool, bool, bool, bool)+0x668
V  [libjvm.so+0xf04cd0]  VM_Operation::evaluate()+0xe0
V  [libjvm.so+0xf0269f]  VMThread::evaluate_operation(VM_Operation*)+0x11f
V  [libjvm.so+0xf02af5]  VMThread::loop()+0x265
V  [libjvm.so+0xf0302c]  VMThread::run()+0x7c
V  [libjvm.so+0xe90fe5]  Thread::call_run()+0x155
V  [libjvm.so+0xc1a878]  thread_native_entry(Thread*)+0xf8

Resolution

Fix the underlying JNI code.

Root Cause

There is JNI code that does not call DetachCurrentThread after using AttachCurrentThreadAsDaemon, resulting in jstack trying to access a bad memory addresss.

This content is not included.OpenJDK 11 crashes when calling jstack on the JVM process


This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.