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

JVMTI SuspendResume1 test fails with invalid thread state #16690

Closed
dipak-bagadiya opened this issue Feb 8, 2023 · 8 comments
Closed

JVMTI SuspendResume1 test fails with invalid thread state #16690

dipak-bagadiya opened this issue Feb 8, 2023 · 8 comments

Comments

@dipak-bagadiya
Copy link
Contributor

dipak-bagadiya commented Feb 8, 2023

Issue

JVMTI GetThreadState returns 0 (invalid state) for the carrier thread when a virtual thread is mounted. 0 refers to a thread which has not started but this state is invalid for the carrier thread. In jvmtiHelpers.c::getThreadState, getVMThreadObjectStatesAll returns J9VMTHREAD_STATE_UNKNOWN for the carrier thread. This will require further investigation.

JVMTI Spec

GetThreadState: https://download.java.net/java/early_access/jdk19/docs/specs/jvmti.html#GetThreadState

Test CMD

make test TEST="jtreg:test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1" JTREG="JAVA_OPTIONS=--enable-preview -Dvm.continuations=true;VERBOSE=all"

Test Output

## Agent: thread[7] 0x7f0a4000b208 ForkJoinPool-1-worker-8: state after suspend: <none> (0)
## Agent: FAILED: SuspendThread did not turn on SUSPENDED flag for carrier thread:
#  state: <none> (0)
## Agent: SuspendThread:  virtual thread of carrier thread has state:  ALIVE RUNNABLE SUSPENDED (1048581)
STDERR:

Fatal error: check_resumed_state: expected SUSPENDED flag in thread state.
@babsingh babsingh changed the title JVMTI SuspendResume1 Test Failed with ** ASSERTION FAILED ** at swalk.c:1632 JVMTI SuspendResume1 test fails with an assertion at swalk.c:1632 Feb 8, 2023
@babsingh
Copy link
Contributor

babsingh commented Feb 8, 2023

Duplicate of #15939. @fengxue-IS Can you point us to the PR which contains the fix for this issue?

@babsingh babsingh added this to the Java 20 milestone Feb 8, 2023
@fengxue-IS
Copy link
Contributor

see #16374

@babsingh
Copy link
Contributor

babsingh commented Feb 8, 2023

@dipak-bagadiya Can you check if changes from #16374 are included in your local workspace? If not, fetch these changes and verify if the reported failure is fixed.

@dipak-bagadiya
Copy link
Contributor Author

dipak-bagadiya commented Feb 10, 2023

@fengxue-IS @babsingh
After #16374's change, the SuspendResume1 test no longer failed with ** ASSERTION FAILED ** at swalk.c, but still it returned the following error.

## Agent: thread[7] 0x7f0a4000b208 ForkJoinPool-1-worker-8: state after suspend: <none> (0)
## Agent: FAILED: SuspendThread did not turn on SUSPENDED flag for carrier thread:
#  state: <none> (0)
## Agent: SuspendThread:  virtual thread of carrier thread has state:  ALIVE RUNNABLE SUSPENDED (1048581)
STDERR:

Fatal error: check_resumed_state: expected SUSPENDED flag in thread state.

The aforementioned problem/error doesn't occur all the time.

@vij-singh
Copy link

What's the next step with this issue? (and who should own it?)

@babsingh babsingh removed the comp:jit label Feb 21, 2023
@babsingh
Copy link
Contributor

What's the next step with this issue? (and who should own it?)

VM team owns it. Updated issue's description and labels (fyi @dipak-bagadiya). The Invalid JIT return address issue was resolved with #16374.

@babsingh babsingh changed the title JVMTI SuspendResume1 test fails with an assertion at swalk.c:1632 JVMTI SuspendResume1 test fails with invalid thread state Feb 21, 2023
dipak-bagadiya added a commit to dipak-bagadiya/openj9 that referenced this issue Mar 2, 2023
JVMTI GetThreadState returns 0 (invalid state) for carrier threads
when a virtual thread is mounted over them. 0 indicates that the
thread has not started but this state is invalid for the carrier
threads when they have a virtual thread mounted.

Helper function getThreadState should not be given virtual thread
objects. It should only receive platform thread objects. Instead of
targetThread->threadObject which can be a virtual thread object, it is
given targetThread->carrierThreadObject to correctly evaluate the
state of carrier threads. This change should also be compatible with
all platform threads since carrierThreadObject is set only once during
thread creation, and it stays the same until thread termination.

Related: eclipse-openj9#16690

Signed-off-by: Dipak Bagadiya <dipak.bagadiya@ibm.com>
@babsingh
Copy link
Contributor

babsingh commented Mar 6, 2023

Fixed by #16805. Will close this issue after the fix is delivered to the v0.37.0-release branch.

@babsingh babsingh closed this as completed Mar 6, 2023
@babsingh babsingh added the jdk19 label Mar 6, 2023
@babsingh babsingh modified the milestones: Java 20 0.39?, Java 19 0.37 Mar 6, 2023
@babsingh babsingh reopened this Mar 6, 2023
@tajila tajila added the comp:vm label Mar 7, 2023
dipak-bagadiya added a commit to dipak-bagadiya/openj9 that referenced this issue Mar 7, 2023
JVMTI GetThreadState returns 0 (invalid state) for carrier threads
when a virtual thread is mounted over them. 0 indicates that the
thread has not started but this state is invalid for the carrier
threads when they have a virtual thread mounted.

Helper function getThreadState should not be given virtual thread
objects. It should only receive platform thread objects. Instead of
targetThread->threadObject which can be a virtual thread object, it is
given targetThread->carrierThreadObject to correctly evaluate the
state of carrier threads. This change should also be compatible with
all platform threads since carrierThreadObject is set only once during
thread creation, and it stays the same until thread termination.

Related: eclipse-openj9#16690

Signed-off-by: Dipak Bagadiya <dipak.bagadiya@ibm.com>
@babsingh
Copy link
Contributor

babsingh commented Mar 7, 2023

Closing. Fix backported to the 0.37 release branch: #16843.

@babsingh babsingh closed this as completed Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants