Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize J9JavaVM->liveVirtualThreadList at startup #16384

Closed
wants to merge 1 commit into from

Conversation

babsingh
Copy link
Contributor

@babsingh babsingh commented Nov 29, 2022

This change fixes the below deadlock.

Thread 1 wants exclusive VM access but it is unable to acquire
exclusive VM access because Thread 2 also holds VM access.
Thread 2 is waiting to acquire liveVirtualThreadListMutex and
unable to proceed because Thread 1 holds liveVirtualThreadListMutex.
This prevents both threads to proceed and leads to a deadlock.

Thread 1: JVM_VirtualThreadMountEnd
           -> Acquires VM Access and liveVirtualThreadListMutex
           -> J9AllocateObject
           -> Multiple GC frames
           -> acquireExclusiveVMAccess

Thread 2: JVM_VirtualThreadMountEnd
           -> Acquires VM Access
           -> Blocked to enter liveVirtualThreadListMutex

Related: #16340 (comment)

Signed-off-by: Babneet Singh sbabneet@ca.ibm.com

@babsingh babsingh force-pushed the null_checks_vt_list branch from 727c187 to f10155c Compare November 29, 2022 23:53
This change fixes the below deadlock.

Thread 1 wants exclusive VM access but it is unable to acquire
exclusive VM access because Thread 2 also holds VM access.
Thread 2 is waiting to acquire liveVirtualThreadListMutex and
unable to proceed because Thread 1 holds liveVirtualThreadListMutex.
This prevents both threads to proceed and leads to a deadlock.

Thread 1: JVM_VirtualThreadMountEnd
           -> Acquires VM Access and liveVirtualThreadListMutex
           -> J9AllocateObject
           -> Multiple GC frames
           -> acquireExclusiveVMAccess

Thread 2: JVM_VirtualThreadMountEnd
           -> Acquires VM Access
           -> Blocked to enter liveVirtualThreadListMutex

Related: eclipse-openj9#16340

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
@babsingh babsingh force-pushed the null_checks_vt_list branch from f10155c to 7121794 Compare November 30, 2022 00:21
@babsingh babsingh marked this pull request as ready for review November 30, 2022 00:24
@babsingh
Copy link
Contributor Author

jenkins test sanity amac jdk19

@babsingh
Copy link
Contributor Author

babsingh commented Nov 30, 2022

https://openj9-jenkins.osuosl.org/job/Test_openjdk19_j9_sanity.functional_aarch64_mac_Personal/94/tapResults/

Multiple failures observed; it may not be feasible to adopt this solution; alternate solution created: #16389.

Testing: -Xlockword minimizeFootprint mode
Test start time: 2022/11/30 13:08:41 Australian Eastern Standard Time
Running command: "/Users/jenkins/workspace/Test_openjdk19_j9_sanity.functional_aarch64_mac_Personal_testList_0/openjdkbinary/j2sdk-image/bin/java"   -Xdump -cp "/Users/jenkins/workspace/Test_openjdk19_j9_sanity.functional_aarch64_mac_Personal_testList_0/aqa-tests/TKG/../../jvmtest/functional/cmdLineTests/utils/utils.jar" -Xlockword:mode=minimizeFootprint VMBench.FibBench
Time spent starting: 1 milliseconds
Time spent executing: 192 milliseconds
Test result: FAILED
Output from test:
 [ERR] Exception in thread "main" java/lang/ExceptionInInitializerError
 [ERR] 	at java/util/concurrent/atomic/Striped64.<clinit> (java.base@19.0.1-internal/Striped64.java:403)
 [ERR] 	at jdk/internal/vm/ThreadContainers$RootContainer$CountingRootContainer.<clinit> (java.base@19.0.1-internal/ThreadContainers.java:256)
 [ERR] 	at jdk/internal/vm/ThreadContainers$RootContainer.<clinit> (java.base@19.0.1-internal/ThreadContainers.java:197)
 [ERR] 	at jdk/internal/vm/ThreadContainers.root (java.base@19.0.1-internal/ThreadContainers.java:86)
 [ERR] 	at jdk/internal/vm/SharedThreadContainer.create (java.base@19.0.1-internal/SharedThreadContainer.java:100)
 [ERR] 	at java/util/concurrent/ForkJoinPool.<init> (java.base@19.0.1-internal/ForkJoinPool.java:2777)
 [ERR] 	at java/util/concurrent/ForkJoinPool.<clinit> (java.base@19.0.1-internal/ForkJoinPool.java:3778)
 [ERR] 	at java/lang/VirtualThread.lambda$createDefaultScheduler$5 (java.base@19.0.1-internal/VirtualThread.java:1051)
 [ERR] 	at java/security/AccessController.doPrivileged (java.base@19.0.1-internal/AccessController.java:692)
 [ERR] 	at java/lang/VirtualThread.createDefaultScheduler (java.base@19.0.1-internal/VirtualThread.java:1054)
 [ERR] 	at java/lang/VirtualThread.<clinit> (java.base@19.0.1-internal/VirtualThread.java:73)
 [ERR] java/lang/NoSuchFieldException: no such field: java.util.concurrent.atomic.Striped64.base/long/getField
 [ERR] 	at java/lang/invoke/MemberName.makeAccessException (java.base@19.0.1-internal/MemberName.java:978)
 [ERR] 	at java/lang/invoke/MemberName$Factory.resolveOrFail (java.base@19.0.1-internal/MemberName.java:1117)
 [ERR] 	at java/lang/invoke/MethodHandles$Lookup.resolveOrFail (java.base@19.0.1-internal/MethodHandles.java:3662)
 [ERR] 	at java/lang/invoke/MethodHandles$Lookup.findVarHandle (java.base@19.0.1-internal/MethodHandles.java:3137)
 [ERR] 	at java/util/concurrent/atomic/Striped64.<clinit> (java.base@19.0.1-internal/Striped64.java:386)
 [ERR] 	at jdk/internal/vm/ThreadContainers$RootContainer$CountingRootContainer.<clinit> (java.base@19.0.1-internal/ThreadContainers.java:256)
 [ERR] 	at jdk/internal/vm/ThreadContainers$RootContainer.<clinit> (java.base@19.0.1-internal/ThreadContainers.java:197)
 [ERR] 	at jdk/internal/vm/ThreadContainers.root (java.base@19.0.1-internal/ThreadContainers.java:86)
 [ERR] 	at jdk/internal/vm/SharedThreadContainer.create (java.base@19.0.1-internal/SharedThreadContainer.java:100)
 [ERR] 	at java/util/concurrent/ForkJoinPool.<init> (java.base@19.0.1-internal/ForkJoinPool.java:2777)
 [ERR] 	at java/util/concurrent/ForkJoinPool.<clinit> (java.base@19.0.1-internal/ForkJoinPool.java:3778)
 [ERR] 	at java/lang/VirtualThread.lambda$createDefaultScheduler$5 (java.base@19.0.1-internal/VirtualThread.java:1051)
 [ERR] 	at java/security/AccessController.doPrivileged (java.base@19.0.1-internal/AccessController.java:692)
 [ERR] 	at java/lang/VirtualThread.createDefaultScheduler (java.base@19.0.1-internal/VirtualThread.java:1054)
 [ERR] 	at java/lang/VirtualThread.<clinit> (java.base@19.0.1-internal/VirtualThread.java:73)
>> Success condition was not found: [Return code: 0]


Testing: Simple Sanity Run and Use Cache
Test start time: 2022/11/30 13:10:38 Australian Eastern Standard Time
Running command: "/Users/jenkins/workspace/Test_openjdk19_j9_sanity.functional_aarch64_mac_Personal_testList_0/openjdkbinary/j2sdk-image/bin/java"  -Xjit -Xgcpolicy:gencon -Xnocompressedrefs  -Xshareclasses:name=HelloWorldSanity -cp /Users/jenkins/workspace/Test_openjdk19_j9_sanity.functional_aarch64_mac_Personal_testList_0/aqa-tests/TKG/../../jvmtest/functional/cmdLineTests/utils/utils.jar VMBench.FibBench
Time spent starting: 2 milliseconds
Time spent executing: 8786 milliseconds
Test result: FAILED
 [ERR] 02:10:38.244 0x13108ff00    j9vm.225    *   ** ASSERTION FAILED ** at /Users/jenkins/workspace/Build_JDK19_aarch64_mac_Personal/openj9/runtime/vm/VMAccess.cpp:134: (!(vmThread->inNative))
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant