Calling Thread.getAllStackTraces() while more than one thread is running, fails with the following error:
```No Java synchronization must be performed within a VMOperation: if the object is already locked, the VM is at a deadlock
Fatal error: Should not reach here: Not okay to block.
JavaFrameAnchor dump:
No anchors
TopFrame info:
TotalFrameSize in CodeInfoTable 32
VMThreads info:
VMThread 000001bfac3bb140 STATUS_IN_SAFEPOINT java.lang.Thread@0x1bfacb022e0
VMThread 000001bfac3b7d80 STATUS_IN_JAVA (safepoints disabled) java.lang.Thread@0x1bfac934190
VM Thread State for current thread 000001bfac3b7d80:
0 (8 bytes): com.oracle.svm.jni.JNIThreadLocalEnvironment.jniFunctions = (bytes)
000001bfac3b7d80: 000001bfac89cfc8
8 (32 bytes): com.oracle.svm.core.genscavenge.ThreadLocalAllocation.regularTLAB = (bytes)
000001bfac3b7d88: 000001bfacb00000 000001bfacc00000
000001bfac3b7d98: 000001bfacb02e30 0000000000000000
40 (8 bytes): com.oracle.svm.core.heap.NoAllocationVerifier.openVerifiers = (Object) null
48 (8 bytes): com.oracle.svm.core.jdk.IdentityHashCodeSupport.hashCodeGeneratorTL = (Object) null
56 (8 bytes): com.oracle.svm.core.snippets.SnippetRuntime.currentException = (Object) null
64 (8 bytes): com.oracle.svm.core.thread.JavaThreads.currentThread = (Object) java.lang.Thread 000001bfac934190
72 (8 bytes): com.oracle.svm.core.thread.ThreadingSupportImpl.activeTimer = (Object) null
80 (8 bytes): com.oracle.svm.jni.JNIObjectHandles.handles = (Object) com.oracle.svm.core.handles.ThreadLocalHandles 000001bfacb01428
88 (8 bytes): com.oracle.svm.jni.JNIThreadLocalPendingException.pendingException = (Object) null
96 (8 bytes): com.oracle.svm.jni.JNIThreadLocalPinnedObjects.pinnedObjectsListHead = (Object) null
104 (8 bytes): com.oracle.svm.jni.JNIThreadOwnedMonitors.ownedMonitors = (Object) null
112 (8 bytes): com.oracle.svm.core.genscavenge.ThreadLocalAllocation.freeList = (Word) 0 0000000000000000
120 (8 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.stackBoundaryTL = (Word) 1 0000000000000001
128 (8 bytes): com.oracle.svm.core.stack.JavaFrameAnchors.lastAnchor = (Word) 0 0000000000000000
136 (8 bytes): com.oracle.svm.core.thread.VMThreads.IsolateTL = (Word) 1922742878208 000001bfac680000
144 (8 bytes): com.oracle.svm.core.thread.VMThreads.OSThreadHandleTL = (Word) 164 00000000000000a4
152 (8 bytes): com.oracle.svm.core.thread.VMThreads.OSThreadIdTL = (Word) 7308 0000000000001c8c
160 (8 bytes): com.oracle.svm.core.thread.VMThreads.nextTL = (Word) 0 0000000000000000
168 (4 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.yellowZoneStateTL = (int) -16843010 fefefefe
172 (4 bytes): com.oracle.svm.core.snippets.ImplicitExceptions.implicitExceptionsAreFatal = (int) 0 00000000
176 (4 bytes): com.oracle.svm.core.thread.Safepoint.safepointRequested = (int) 2147473412 7fffd804
180 (4 bytes): com.oracle.svm.core.thread.ThreadingSupportImpl.currentPauseDepth = (int) 1 00000001
184 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.safepointsDisabledTL = (int) 1 00000001
188 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.statusTL = (int) 1 00000001
VMOperation dump:
VMOperation in progress: getAllStackTraces
causesSafepoint: true
queuingThread: 000001bfac3b7d80
executingThread: 000001bfac3b7d80
Dump Counters:
Raw Stacktrace:
000000bc7a2ff6d0: 000001bfac8d1500 000001bfac7ea518
000000bc7a2ff6e0: 000001bfac680000 00007ff669b6d6fc
000000bc7a2ff6f0: 000001bfac8d150a 00007ff669b693c9
000000bc7a2ff700: 0000000000000001 00007ff669b4149b
000000bc7a2ff710: 000001bfac7744e8 000001bfac7e6578
000000bc7a2ff720: 00000002002b3bb8 00007ff669b12c58
000000bc7a2ff730: 000001bfac885680 000001bfac680018
000000bc7a2ff740: 000001bfac7e8e70 00007ff669b4abbf
000000bc7a2ff750: 0000000000002df5 0000000000000001
000000bc7a2ff760: 00000098ac3b8608 0000000000015729
000000bc7a2ff770: 00000001acb02d40 000001bfac7e8e70
000000bc7a2ff780: 0000000000015700 0000000000015729
000000bc7a2ff790: 000001bfac92c860 00007ff669b5fe6b
000000bc7a2ff7a0: 0000000000482d40 000001bfacb02d40
000000bc7a2ff7b0: 000001bfacb02560 00007ff669cff66a
000000bc7a2ff7c0: 000000bc7a2ff818 00007ff669b60865
000000bc7a2ff7d0: 000001bfacb02e10 00007ff669b475d5
000000bc7a2ff7e0: 000001bfac9f9d50 000001bfacb02e10
000000bc7a2ff7f0: 000001bfacb02560 00007ff669c13a37
000000bc7a2ff800: 00007ff669b5fcb0 000001bfacb026d8
000000bc7a2ff810: 000001bfacb022e0 000000a8ac934398
000000bc7a2ff820: 00000000000000a8 00007ff669bf5819
000000bc7a2ff830: 0000000300000000 0000000000000050
000000bc7a2ff840: 000000087a5ff5d0 00007ff669cdf106
000000bc7a2ff850: 000001bfac3b0000 000001bfacb022e0
000000bc7a2ff860: 000001bfacb02560 00007ff669cdf78b
000000bc7a2ff870: 0000000000000028 00007ff669b62a60
000000bc7a2ff880: 000001bfacb02dc0 000001bfacb022e0
000000bc7a2ff890: 000001bfacb024d8 00007ff669b633f6
000000bc7a2ff8a0: 00006433b373d787 0000000000000002
000000bc7a2ff8b0: 000001bfacb022e0 000001bfacb024d8
000000bc7a2ff8c0: 000001bfac3bb140 00007ff669b61430
000000bc7a2ff8d0: 000001bfac3b7d80 000001bfac3c3418
000000bc7a2ff8e0: 00007ff669b6e800 00007ff669b64fd4
000000bc7a2ff8f0: 000001bfac8d1000 00007ffdea8a234f
000000bc7a2ff900: 000001bfacb02520 00007ff669b65618
000000bc7a2ff910: 00007ff669b266b0 000001bfacb02520
000000bc7a2ff920: 000001bfacb02520 00007ff669b67fb4
000000bc7a2ff930: 0000000000000000 000001bfac680000
000000bc7a2ff940: 000001bfac7e7668 000001bfac680000
000000bc7a2ff950: 00000000002207f0 000001bfacb02520
000000bc7a2ff960: 0000000000000000 0000000000000000
000000bc7a2ff970: 0000000000000000 00007ff669b684ca
000000bc7a2ff980: 000001bfac3b7d80 00007ff669b669b6
000000bc7a2ff990: 000001bfaca01828 000001bfaca01828
000000bc7a2ff9a0: 000001bfacb02520 000001bfaca017d8
000000bc7a2ff9b0: 000001bfac886778 00007ff669b68c1b
000000bc7a2ff9c0: 00000000002207f0 000001bfacb02520
000000bc7a2ff9d0: 000001bfac7e9fd0 000001bfac7e9fd0
000000bc7a2ff9e0: 000001bfaca017d8 000001bfac8d1070
000000bc7a2ff9f0: 000001bfaca01828 000001bfac886778
000000bc7a2ffa00: 0000000100000001 00007ff669b68a24
000000bc7a2ffa10: 00007ff669b6e897 00007ff669b4149b
000000bc7a2ffa20: 000001bfac886778 000001bfacb02520
000000bc7a2ffa30: 0000000000000000 00007ff669b692a1
000000bc7a2ffa40: 000001bfacb022e0 00007ff669d2e767
000000bc7a2ffa50: 00000000000000c8 000001bfac680018
000000bc7a2ffa60: 000001bfacb02520 000001bfac7e7668
000000bc7a2ffa70: 0000000000000000 00007ff669b65400
000000bc7a2ffa80: 00007ff669b6e800 000001bfacb024c0
000000bc7a2ffa90: 000001bfac7e9fd0 00007ff669b6297c
000000bc7a2ffaa0: 00007ff669e17138 00007ff669e1713e
000000bc7a2ffab0: 000001bfacb024d8 00007ff669b11569
000000bc7a2ffac0: 000001bfac7e6418 00007ff669c1503b
Stacktrace Stage0:
RSP 000000bc7a2ff6d0 RIP 00007ff669b6d776 FrameSize 32
RSP 000000bc7a2ff6f0 RIP 00007ff669b6d6fc FrameSize 16
RSP 000000bc7a2ff700 RIP 00007ff669b693c9 FrameSize 48
RSP 000000bc7a2ff730 RIP 00007ff669b12c58 FrameSize 32
RSP 000000bc7a2ff750 RIP 00007ff669b4abbf FrameSize 112
RSP 000000bc7a2ff7c0 RIP 00007ff669cff66a FrameSize 32
RSP 000000bc7a2ff7e0 RIP 00007ff669b475d5 FrameSize 32
RSP 000000bc7a2ff800 RIP 00007ff669c13a37 FrameSize 48
RSP 000000bc7a2ff830 RIP 00007ff669bf5819 FrameSize 32
RSP 000000bc7a2ff850 RIP 00007ff669cdf106 FrameSize 32
RSP 000000bc7a2ff870 RIP 00007ff669cdf78b FrameSize 48
RSP 000000bc7a2ff8a0 RIP 00007ff669b633f6 FrameSize 48
RSP 000000bc7a2ff8d0 RIP 00007ff669b61430 FrameSize 32
RSP 000000bc7a2ff8f0 RIP 00007ff669b64fd4 FrameSize 32
RSP 000000bc7a2ff910 RIP 00007ff669b65618 FrameSize 32
RSP 000000bc7a2ff930 RIP 00007ff669b67fb4 FrameSize 80
RSP 000000bc7a2ff980 RIP 00007ff669b684ca FrameSize 64
RSP 000000bc7a2ff9c0 RIP 00007ff669b68c1b FrameSize 80
RSP 000000bc7a2ffa10 RIP 00007ff669b68a24 FrameSize 48
RSP 000000bc7a2ffa40 RIP 00007ff669b692a1 FrameSize 64
RSP 000000bc7a2ffa80 RIP 00007ff669b65400 FrameSize 32
RSP 000000bc7a2ffaa0 RIP 00007ff669b6297c FrameSize 32
RSP 000000bc7a2ffac0 RIP 00007ff669b11569 FrameSize 48
RSP 000000bc7a2ffaf0 RIP 00007ff669b1131b FrameSize 48
RSP 000000bc7a2ffb20 RIP 00007ff669b2639d FrameSize 1
Stacktrace Stage1:
RSP 000000bc7a2ff6d0 RIP 00007ff669b6d776 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff6f0 RIP 00007ff669b6d6fc com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff700 RIP 00007ff669b693c9 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff730 RIP 00007ff669b12c58 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff750 RIP 00007ff669b4abbf com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff7c0 RIP 00007ff669cff66a com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff7e0 RIP 00007ff669b475d5 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff800 RIP 00007ff669c13a37 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff830 RIP 00007ff669bf5819 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff850 RIP 00007ff669cdf106 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff870 RIP 00007ff669cdf78b com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff8a0 RIP 00007ff669b633f6 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff8d0 RIP 00007ff669b61430 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff8f0 RIP 00007ff669b64fd4 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff910 RIP 00007ff669b65618 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff930 RIP 00007ff669b67fb4 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff980 RIP 00007ff669b684ca com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ff9c0 RIP 00007ff669b68c1b com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ffa10 RIP 00007ff669b68a24 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ffa40 RIP 00007ff669b692a1 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ffa80 RIP 00007ff669b65400 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ffaa0 RIP 00007ff669b6297c com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ffac0 RIP 00007ff669b11569 com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ffaf0 RIP 00007ff669b1131b com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
RSP 000000bc7a2ffb20 RIP 00007ff669b2639d com.oracle.svm.core.code.CodeInfo@0x1bfac92c860 name = image code
Full Stacktrace:
RSP 000000bc7a2ff6d0 RIP 00007ff669b6d776 [image code] com.oracle.svm.core.jdk.VMErrorSubstitutions.shutdown(VMErrorSubstitutions.java:111)
RSP 000000bc7a2ff6d0 RIP 00007ff669b6d776 [image code] com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:74)
RSP 000000bc7a2ff6f0 RIP 00007ff669b6d6fc [image code] com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:59)
RSP 000000bc7a2ff700 RIP 00007ff669b693c9 [image code] com.oracle.svm.core.thread.VMOperationControl.guaranteeOkayToBlock(VMOperationControl.java:276)
RSP 000000bc7a2ff730 RIP 00007ff669b12c58 [image code] com.oracle.svm.core.MonitorSupport.monitorEnter(MonitorSupport.java:138)
RSP 000000bc7a2ff750 RIP 00007ff669b4abbf [image code] com.oracle.svm.core.jdk.SplittableRandomAccessors.initialize(JavaUtilSubstitutions.java:267)
RSP 000000bc7a2ff7c0 RIP 00007ff669cff66a [image code] com.oracle.svm.core.jdk.SplittableRandomAccessors.getDefaultGen(JavaUtilSubstitutions.java:260)
RSP 000000bc7a2ff7c0 RIP 00007ff669cff66a [image code] java.util.SplittableRandom.
RSP 000000bc7a2ff7e0 RIP 00007ff669b475d5 [image code] com.oracle.svm.core.jdk.IdentityHashCodeSupport.generateHashCode(IdentityHashCodeSupport.java:43)
RSP 000000bc7a2ff800 RIP 00007ff669c13a37 [image code] java.lang.System.identityHashCode(System.java:309)
RSP 000000bc7a2ff830 RIP 00007ff669bf5819 [image code] java.lang.Object.hashCodeSubst(Object.java:102)
RSP 000000bc7a2ff850 RIP 00007ff669cdf106 [image code] java.util.HashMap.hash(HashMap.java:339)
RSP 000000bc7a2ff870 RIP 00007ff669cdf78b [image code] java.util.HashMap.put(HashMap.java:607)
RSP 000000bc7a2ff8a0 RIP 00007ff669b633f6 [image code] com.oracle.svm.core.thread.JavaThreads.lambda$getAllStackTraces$1(JavaThreads.java:539)
RSP 000000bc7a2ff8d0 RIP 00007ff669b61430 [image code] com.oracle.svm.core.thread.JavaThreads$$Lambda$91a7d87fc99e4d13115449c8034607abad6591ed.invoke(Unknown Source)
RSP 000000bc7a2ff8f0 RIP 00007ff669b64fd4 [image code] com.oracle.svm.core.thread.JavaVMOperation$ThunkOperation.operate(JavaVMOperation.java:132)
RSP 000000bc7a2ff910 RIP 00007ff669b65618 [image code] com.oracle.svm.core.thread.JavaVMOperation.operate(JavaVMOperation.java:115)
RSP 000000bc7a2ff930 RIP 00007ff669b67fb4 [image code] com.oracle.svm.core.thread.VMOperation.execute(VMOperation.java:89)
RSP 000000bc7a2ff980 RIP 00007ff669b684ca [image code] com.oracle.svm.core.thread.VMOperationControl$WorkQueues.drain(VMOperationControl.java:532)
RSP 000000bc7a2ff9c0 RIP 00007ff669b68c1b [image code] com.oracle.svm.core.thread.VMOperationControl$WorkQueues.executeAllQueuedVMOperations(VMOperationControl.java:486)
RSP 000000bc7a2ffa10 RIP 00007ff669b68a24 [image code] com.oracle.svm.core.thread.VMOperationControl$WorkQueues.enqueueAndExecute(VMOperationControl.java:429)
RSP 000000bc7a2ffa40 RIP 00007ff669b692a1 [image code] com.oracle.svm.core.thread.VMOperationControl.enqueue(VMOperationControl.java:249)
RSP 000000bc7a2ffa80 RIP 00007ff669b65400 [image code] com.oracle.svm.core.thread.VMOperationControl.enqueue(VMOperationControl.java:213)
RSP 000000bc7a2ffa80 RIP 00007ff669b65400 [image code] com.oracle.svm.core.thread.JavaVMOperation.enqueue(JavaVMOperation.java:69)
RSP 000000bc7a2ffa80 RIP 00007ff669b65400 [image code] com.oracle.svm.core.thread.JavaVMOperation.enqueueBlockingSafepoint(JavaVMOperation.java:104)
RSP 000000bc7a2ffaa0 RIP 00007ff669b6297c [image code] com.oracle.svm.core.thread.JavaThreads.getAllStackTraces(JavaThreads.java:537)
RSP 000000bc7a2ffac0 RIP 00007ff669b11569 [image code] java.lang.Thread.getAllStackTraces(Thread.java:385)
RSP 000000bc7a2ffac0 RIP 00007ff669b11569 [image code] AllStackTraces.printAllStackTraces(AllStackTraces.java:29)
RSP 000000bc7a2ffaf0 RIP 00007ff669b1131b [image code] AllStackTraces.main(AllStackTraces.java:24)
RSP 000000bc7a2ffb20 RIP 00007ff669b2639d [image code] com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:151)
RSP 000000bc7a2ffb20 RIP 00007ff669b2639d [image code] com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
RSP 000000bc7a2ffb20 RIP 00007ff669b2639d [image code] com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(IsolateEnterStub.java:0)
Full Stacktrace for VMThread 000001bfac3bb140:
RSP 000000bc7a5ff5d0 RIP 00007ff669b6eab5 [image code] com.oracle.svm.core.windows.headers.SynchAPI.WaitForSingleObject(SynchAPI.java)
RSP 000000bc7a5ff5d0 RIP 00007ff669b6eab5 [image code] com.oracle.svm.core.windows.WindowsParkEvent.condTimedWait(WindowsJavaThreads.java:226)
RSP 000000bc7a5ff640 RIP 00007ff669b63ddd [image code] com.oracle.svm.core.thread.JavaThreads.sleep(JavaThreads.java:706)
RSP 000000bc7a5ff6e0 RIP 00007ff669c1503b [image code] java.lang.Thread.sleep(Thread.java:349)
RSP 000000bc7a5ff700 RIP 00007ff669c14782 [image code] AllStackTraces$1.run(AllStackTraces.java:12)
RSP 000000bc7a5ff700 RIP 00007ff669c14782 [image code] java.lang.Thread.run(Thread.java:834)
RSP 000000bc7a5ff720 RIP 00007ff669b647de [image code] com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:497)
RSP 000000bc7a5ff750 RIP 00007ff669b6d9cf [image code] com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:136)
RSP 000000bc7a5ff7a0 RIP 00007ff669b26729 [image code] com.oracle.svm.core.code.IsolateEnterStub.WindowsJavaThreads_osThreadStartRoutine_4bc03aa26f8cdfc97ebd54050e8ae4bce1023851(IsolateEnterStub.java:0)
[Native image heap boundaries:
ReadOnly Primitives: 0x1bfac680008 .. 0x1bfac7e6188
ReadOnly References: 0x1bfac7e6418 .. 0x1bfac8d0e88
Writable Primitives: 0x1bfac8d1000 .. 0x1bfac9338a8
Writable References: 0x1bfac9338c0 .. 0x1bfaca034a8]
[Heap:
[Young generation:
[youngSpace:
aligned: 0/0 unaligned: 0/0]]
[Old generation:
[fromSpace:
aligned: 0/0 unaligned: 0/0]
[toSpace:
aligned: 0/0 unaligned: 0/0]
]
[Unused:
aligned: 0/0]]
Fatal error: Should not reach here: Not okay to block.```
This is a sample Java program that produces the error.
import java.util.Map;
import java.util.Map.Entry;
public class AllStackTraces {
public static void main(String[] args) throws InterruptedException {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
break;
}
}
}
}, "Sleeping Thread");
thread.setDaemon(true);
thread.start();
for (int i = 0; i < 5; i++) {
Thread.sleep(1000);
printAllStackTraces();
}
}
public static void printAllStackTraces() {
Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
System.out.println("Number of threads: " + traces.size());
}
}
When you comment the line with thread.start(), the application does not fail.
@arodionov has this been merged?
@cstancu any word on this issue it is vital for the windows javafx native image support @tiainen doing great efforts on that .....so please put it on high priority do not put it on hold sorry to say that BUT several javafx native image issues in freeze again I am sorry to say that this issue opened on Jan 27.
@arodionov has this been merged?
Yes, it has been merged.
I can confirm that it indeed works now.
Most helpful comment
I can confirm that it indeed works now.