VM Crash: Same thread Executor
Ron Pressler
ron.pressler at oracle.com
Tue Aug 11 20:32:31 UTC 2020
Thank you for reporting this.
While this crash is, indeed, a bug that we'll look into, a "same-thread"
executor written like the one in your example won't work as you'd expect. The
virtual threads won't all be scheduled on the same thread, but on whichever
thread unblocks them. This will cause deadlocks and might even throw exceptions
due to races (although it shouldn't crash the VM...). What you're looking for is
a "single-thread" executor, created with Executors.newSingleThreadScheduledExecutor
(or with EventQueue::invokeLater, although that won't currently work because there
are thread identity tests in UI code; this is being worked on).
- Ron
On 11 August 2020 at 20:28:51, Thomas May (tmay at clearwateranalytics.com(mailto:tmay at clearwateranalytics.com)) wrote:
> The following code intermittently crashes 16-loom+4-56 (It's crashed on me 3 out of 4 times).
>
> public class Main {
> public static void main(String[] args) {
> try (var e = Executors.newThreadExecutor(Thread.builder().daemon(true).virtual(Runnable::run).factory())) {
> for (int i = 0; i < 10000000; ++i) {
> int j = i;
> e.submit(()->{
> try {
> Thread.sleep(1000);
> System.out.println(j);
> } catch (Exception ex) {
> throw new RuntimeException(ex);
> }
> });
> }
> }
> }
> }
>
> I was testing the notion of using loom to issue concurrent tasks on the same thread that the service was created on. This would be useful in cases such as Swing where you might want to thread out a bunch of io and have it update the gui on return.
>
> Let me know if you need more information.
>
> Here's the first portion of the crash log
>
> #
> # A fatal error has been detected by the Java Runtime Environment:
> #
> # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffa051b284d, pid=9456, tid=14092
> #
> # JRE version: OpenJDK Runtime Environment (16.0+4) (build 16-loom+4-56)
> # Java VM: OpenJDK 64-Bit Server VM (16-loom+4-56, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
> # Problematic frame:
> # V [jvm.dll+0x2f284d]
> #
> # No core dump will be written. Minidumps are not enabled by default on client versions of Windows
> #
> # If you would like to submit a bug report, please visit:
> # https://bugreport.java.com/bugreport/crash.jsp
> #
>
> --------------- S U M M A R Y ------------
>
> Command Line: -Dfile.encoding=windows-1252 C:\dev\garbage\target\garbage-1.0-SNAPSHOT.jar
>
> Host: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz, 12 cores, 15G, Windows 10 , 64 bit Build 19041 (10.0.19041.292)
> Time: Tue Aug 11 13:03:40 2020 Mountain Daylight Time elapsed time: 6.841591 seconds (0d 0h 0m 6s)
>
> --------------- T H R E A D ---------------
>
> Current thread (0x000001319c0574d0): ConcurrentGCThread "G1 Conc#2" [stack: 0x0000002a13800000,0x0000002a13900000] [id=14092]
>
> Stack: [0x0000002a13800000,0x0000002a13900000], sp=0x0000002a138ffa10, free space=1022k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
> V [jvm.dll+0x2f284d]
> V [jvm.dll+0x30a86e]
> V [jvm.dll+0x307101]
> V [jvm.dll+0x308cbc]
> V [jvm.dll+0x3079b4]
> V [jvm.dll+0x30b256]
> V [jvm.dll+0x81eae0]
> V [jvm.dll+0x7ae6ba]
> V [jvm.dll+0x6931d6]
> C [ucrtbase.dll+0x21542]
> C [KERNEL32.DLL+0x16fd4]
> C [ntdll.dll+0x4cec1]
>
>
> siginfo: EXCEPTION_ACCESS_VIOLATION (0xc0000005), reading address 0x00007ffa0f1f8460
>
>
> Register to memory mapping:
>
> RIP=0x00007ffa051b284d jvm.dll
> RAX=0x00007ffa05938458 jvm.dll
> RBX=0x0000000000000014 is an unknown value
> RCX=0x0000002a138ffb40 points into unknown readable memory: 0x00007ffa057b8958 | 58 89 7b 05 fa 7f 00 00
> RDX=0x00000007677b7910 is pointing into object: jdk.internal.misc.StackChunk
> {0x00000007677b7770} - klass: 'jdk/internal/misc/StackChunk'
> RSP=0x0000002a138ffa10 points into unknown readable memory: 0x0000000800b9d170 | 70 d1 b9 00 08 00 00 00
> RBP=0x0000002a138ffb40 points into unknown readable memory: 0x00007ffa057b8958 | 58 89 7b 05 fa 7f 00 00
> RSI=0x00000007677b7910 is pointing into object: jdk.internal.misc.StackChunk
> {0x00000007677b7770} - klass: 'jdk/internal/misc/StackChunk'
> RDI=0x0000000800000008 is pointing into metadata
> R8 =0x0000000800000008 is pointing into metadata
> R9 =0x0000000001318001 is an unknown value
> R10=0x0000000800000000 is pointing into metadata
> R11=0x0000002a138ff8e0 points into unknown readable memory: 0x000001319c1eb218 | 18 b2 1e 9c 31 01 00 00
> R12=0x0 is NULL
> R13=0x0000000000000001 is an unknown value
> R14=0x0000000000000002 is an unknown value
> R15=0x0000002a138ffb00 points into unknown readable memory: 0x00000131f7358a70 | 70 8a 35 f7 31 01 00 00
>
>
> Registers:
> RAX=0x00007ffa05938458, RBX=0x0000000000000014, RCX=0x0000002a138ffb40, RDX=0x00000007677b7910
> RSP=0x0000002a138ffa10, RBP=0x0000002a138ffb40, RSI=0x00000007677b7910, RDI=0x0000000800000008
> R8 =0x0000000800000008, R9 =0x0000000001318001, R10=0x0000000800000000, R11=0x0000002a138ff8e0
> R12=0x0000000000000000, R13=0x0000000000000001, R14=0x0000000000000002, R15=0x0000002a138ffb00
> RIP=0x00007ffa051b284d, EFLAGS=0x0000000000010206
>
> Top of Stack: (sp=0x0000002a138ffa10)
> 0x0000002a138ffa10: 0000000800b9d170 0000000000000003
> 0x0000002a138ffa20: 0000002a138ffb40 0000000000000000
> 0x0000002a138ffa30: 00000131f7375510 00007ffa051ca86e
> 0x0000002a138ffa40: 00000007677b7910 00000131f7358a80
> 0x0000002a138ffa50: 0000002a138ffb00 000000000c636eb7
> 0x0000002a138ffa60: 00000007677b7910 00007ffa051c7101
> 0x0000002a138ffa70: 000000000c636f22 0000000000000040
> 0x0000002a138ffa80: 00000007677b72d8 00007ffa051c85f4
> 0x0000002a138ffa90: 000000000c640000 00007ffa051c8cbc
> 0x0000002a138ffaa0: 00000007677b75c8 000000000c636f22
> 0x0000002a138ffab0: 000000000119557c 000000000007270e
> 0x0000002a138ffac0: 000001319b813201 0000000000000002
> 0x0000002a138ffad0: 00000131f7375510 00007ffa051c79b4
> 0x0000002a138ffae0: aaaaaaaaaaaaaaab 00000131f7358a70
> 0x0000002a138ffaf0: 0000000000000000 0000000000000000
> 0x0000002a138ffb00: 00000131f7358a70 00000131f7375510
>
> Instructions: (pc=0x00007ffa051b284d)
> 0x00007ffa051b274d: c1 7d 09 48 c7 c0 f0 ff ff ff eb 0e 48 2b c1 48
> 0x00007ffa051b275d: 63 0d b1 81 68 00 48 0f af c1 49 8b 3c 06 49 8d
> 0x00007ffa051b276d: 1c 06 48 8b 45 20 48 ff 80 c0 00 00 00 66 83 fa
> 0x00007ffa051b277d: 01 75 1a 8b 0b 85 c9 74 24 8b d1 8b 0d 82 51 78
> 0x00007ffa051b278d: 00 48 d3 e2 48 03 15 70 51 78 00 eb 06 48 8b 13
> 0x00007ffa051b279d: 48 85 d2 74 08 48 8b c8 e8 a6 2b 00 00 48 3b 3b
> 0x00007ffa051b27ad: 0f 95 c0 40 0a f0 48 8d 4c 24 20 e8 d3 d5 38 00
> 0x00007ffa051b27bd: e9 4e ff ff ff 48 8b 7c 24 58 40 0f b6 c6 48 8b
> 0x00007ffa051b27cd: 74 24 68 48 8b 5c 24 50 48 8b 6c 24 60 48 83 c4
> 0x00007ffa051b27dd: 40 41 5e c3 cc cc cc cc cc cc cc cc cc cc cc cc
> 0x00007ffa051b27ed: cc cc cc 48 89 5c 24 08 48 89 6c 24 10 48 89 74
> 0x00007ffa051b27fd: 24 18 57 48 83 ec 20 80 3d 16 e0 80 00 00 48 8b
> 0x00007ffa051b280d: ea 48 8b f1 74 15 8b 79 08 8b 0d 04 51 78 00 48
> 0x00007ffa051b281d: d3 e7 48 03 3d f2 50 78 00 eb 04 48 8b 79 08 48
> 0x00007ffa051b282d: 8b d7 48 8b ce e8 c9 f7 e8 ff 4c 63 4f 0c 8b d8
> 0x00007ffa051b283d: 48 8d 05 14 5c 78 00 4c 8b c7 48 8b d6 48 8b cd
> 0x00007ffa051b284d: 42 ff 14 c8 48 8b 6c 24 38 8b c3 48 8b 5c 24 30
> 0x00007ffa051b285d: 48 8b 74 24 40 48 83 c4 20 5f c3 cc cc cc cc cc
> 0x00007ffa051b286d: cc cc cc 40 55 48 83 ec 30 48 89 5c 24 40 48 8b
> 0x00007ffa051b287d: e9 49 8b d8 48 89 74 24 48 44 8b 41 10 45 33 c9
> 0x00007ffa051b288d: 4c 89 74 24 28 4c 89 7c 24 20 4c 8b fa 48 8b d1
> 0x00007ffa051b289d: 48 8b 8b 98 00 00 00 e8 87 5d ed ff 4c 63 53 10
> 0x00007ffa051b28ad: 4c 63 8b 24 01 00 00 49 83 c2 39 8b 83 20 01 00
> 0x00007ffa051b28bd: 00 4d 03 d1 49 03 c2 4a 8d 34 d3 4c 8d 34 c3 49
> 0x00007ffa051b28cd: 3b f6 73 73 48 89 7c 24 50 66 66 0f 1f 84 00 00
> 0x00007ffa051b28dd: 00 00 00 48 63 1e 8b 46 04 49 03 df 48 8d 3c 83
> 0x00007ffa051b28ed: 48 3b df 73 44 0f 1f 40 00 66 66 0f 1f 84 00 00
> 0x00007ffa051b28fd: 00 00 00 48 8b 45 20 48 ff 80 c0 00 00 00 8b 0b
> 0x00007ffa051b290d: 85 c9 74 1c 8b d1 8b 0d f7 4f 78 00 48 d3 e2 48
> 0x00007ffa051b291d: 03 15 e5 4f 78 00 74 08 48 8b c8 e8 23 2a 00 00
> 0x00007ffa051b292d: 48 83 c3 04 48 3b df 72 ca 48 83 c6 08 49 3b f6
> 0x00007ffa051b293d: 72 a1 48 8b 7c 24 50 49 8b cf e8 c4 57 0c 00 4c
>
>
> Stack slot to memory mapping:
> stack at sp + 0 slots: 0x0000000800b9d170 is a pointer to class:
> java.lang.VirtualThread$Runner {0x0000000800b9d178}
> stack at sp + 1 slots: 0x0000000000000003 is an unknown value
> stack at sp + 2 slots: 0x0000002a138ffb40 points into unknown readable memory: 0x00007ffa057b8958 | 58 89 7b 05 fa 7f 00 00
> stack at sp + 3 slots: 0x0 is NULL
> stack at sp + 4 slots: 0x00000131f7375510 points into unknown readable memory: 0x00007ffa057b8938 | 38 89 7b 05 fa 7f 00 00
> stack at sp + 5 slots: 0x00007ffa051ca86e jvm.dll
> stack at sp + 6 slots: 0x00000007677b7910 is pointing into object: jdk.internal.misc.StackChunk
> {0x00000007677b7770} - klass: 'jdk/internal/misc/StackChunk'
> stack at sp + 7 slots: 0x00000131f7358a80 points into unknown readable memory: 0x00007ffa057b8918 | 18 89 7b 05 fa 7f 00 00
>
> ________________________________
>
> NOTICE: This e-mail message, together with any attachments, contains information of Clearwater Analytics and/or its affiliates that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately delete it. The information we provide is from sources Clearwater Analytics considers reliable, but Clearwater Analytics provides no warranties regarding the accuracy of the information. Further, nothing in the email should be construed as legal, financial, or tax advice, and any questions regarding the intended recipient's individual circumstances should be addressed to that recipient's lawyer and/or accountant.
>
> Clearwater Analytics, 777 W. Main St, Boise, ID 83702
> If you prefer not to receive emails from Clearwater Analytics you may unsubscribe.
More information about the loom-dev
mailing list