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

Virtual threads support for jvmtiGetFrameCount #15753

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

thallium
Copy link
Contributor

@thallium thallium commented Aug 19, 2022

Adds walkContinuationStackFrames to internal functions so jvmti code can use it.
Adds a check for whether it's a virtual thread and not yielded or terminated.
If it is, use walkContinuationStackFrames to walk the continuation object.
Issue: #15183 #15759

@babsingh
Copy link
Contributor

babsingh commented Aug 19, 2022

The current problem is that this doesn't compile

Try to fetch the new changes from #15690.

If it still fails to compile, can you post the compilation error here?

runtime/jvmti/jvmtiStackFrame.c Outdated Show resolved Hide resolved
@thallium
Copy link
Contributor Author

The current problem is that this doesn't compile

Try to fetch the new changes from #15690.

If it still fails to compile, can you post the compilation error here?

Actually the error was undefined reference to walkContinuationStackFrames, ended up adding it to internalVMFunctions.

runtime/jvmti/jvmtiStackFrame.c Outdated Show resolved Hide resolved
runtime/jvmti/jvmtiStackFrame.c Outdated Show resolved Hide resolved
@babsingh
Copy link
Contributor

babsingh commented Aug 20, 2022

If needed, request @EricYangIBM's help for running the below tests:

Instructions which were used for https://github.com/ibmruntimes/openj9-openjdk-jdk19/tree/openj9/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState

Get the testimage from the latest AdoptOpenJDK build.
Example: https://ci.adoptopenjdk.net/job/build-scripts/job/jobs/job/jdk19/job/jdk19-linux-x64-temurin/12/artifact/workspace/target/OpenJDK19U-testimage_x64_linux_hotspot_2022-06-23-03-30.tar.gz

# Unzip the testimage
tar -xvzf OpenJDK19U-testimage_x64_linux_hotspot_2022-06-23-03-30.tar.gz

# Copy all shared libraries into the build directory
cp /root/openj9-openjdk-jdk19/jdk-19+27-test-image/hotspot/jtreg/native/* /root/openj9-openjdk-jdk19/build/linux-x86_64-server-release/images/test/hotspot/jtreg/native/.

# Run test
make test TEST="jtreg:test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState" JTREG="JAVA_OPTIONS=--enable-preview"

@fengxue-IS
Copy link
Contributor

fengxue-IS commented Aug 25, 2022

@thallium Can you rebase this change on the new changes from #15766, and test again

@thallium
Copy link
Contributor Author

back to seg fault now:

Testing:
JVMTI Stack Trace for thread VirtualThread-Live: frame count: 8
 0: framecnt01: checkFrames0(Ljava/lang/Thread;ZI)Z
 1: framecnt01: checkFrames(Ljava/lang/Thread;ZI)V
 2: framecnt01: lambda$main$0()V
 3: framecnt01$$Lambda$1/0x00000000ec556238: run()V
 4: java/lang/VirtualThread: run(Ljava/lang/Runnable;)V
 5: java/lang/VirtualThread$VThreadContinuation: lambda$new$0(Ljava/lang/VirtualThread;Ljava/lang/Runnable;)V
 6: java/lang/VirtualThread$VThreadContinuation$$Lambda$7/0x000000009406a100: run()V
 7: jdk/internal/vm/Continuation: execute(Ljdk/internal/vm/Continuation;)V

Testing:
STDERR:
Unhandled exception
Type=Segmentation error vmState=0x00040000
J9Generic_Signal_Number=00000018 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001
Handler1=00007FA6F10D9BA0 Handler2=00007FA6F068DE30 InaccessibleAddress=0000000000000090
RDI=00000000001A8900 RSI=0000000000000000 RAX=0000000000000020 RBX=00000000001A8900
RCX=0000000000001020 RDX=0000000000000020 R8=0000000000000000 R9=0000000000000000
R10=00007FA690004618 R11=0000000000000000 R12=0000000000000000 R13=00007FA6F149D3E0
R14=00007FA6CC593010 R15=0000000000000000
RIP=00007FA6F11240E3 GS=0000 FS=0000 RSP=00007FA6CC592EE0
EFlags=0000000000010246 CS=0033 RBP=00000000001A8998 ERR=0000000000000004
TRAPNO=000000000000000E OLDMASK=0000000000000000 CR2=0000000000000090
xmm0 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm1 50554f52475f4441 (f: 1197425792.000000, d: 9.870048e+78)
xmm2 ffffffffffffffff (f: 4294967296.000000, d: -nan)
xmm3 ff00000000000000 (f: 0.000000, d: -5.486124e+303)
xmm4 61657268545f676e (f: 1415538560.000000, d: 1.507621e+161)
xmm5 6176614a00494a5f (f: 4803167.000000, d: 3.146433e+161)
xmm6 6c735f6461657268 (f: 1634038400.000000, d: 2.608708e+214)
xmm7 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm8 00000000000ce1b0 (f: 844208.000000, d: 4.170942e-318)
xmm9 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm10 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm11 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm12 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm13 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm14 0000000000000000 (f: 0.000000, d: 0.000000e+00)
xmm15 0000000000000000 (f: 0.000000, d: 0.000000e+00)
Module=/root/openj9-openjdk-jdk19/build/linux-x86_64-server-release/images/jdk/lib/default/libj9vm29.so
Module_base_address=00007FA6F109B000
Target=2_90_20220825_000000 (Linux 5.15.0-46-generic)
CPU=amd64 (8 logical CPUs) (0x3e8091000 RAM)
----------- Stack Backtrace -----------
haltThreadForInspection+0xa3 (0x00007FA6F11240E3 [libj9vm29.so+0x890e3])
jvmtiGetStackTrace+0x159 (0x00007FA6E9ADDE29 [libj9jvmti29.so+0x28e29])
_ZL17print_stack_traceP9_jvmtiEnvP7JNIEnv_P8_jobject+0x61 (0x00007FA6F2782D41 [libframecnt01.so+0x1d41])
Java_framecnt01_checkFrames0+0x51 (0x00007FA6F2783A31 [libframecnt01.so+0x2a31])
ffi_call_unix64+0x52 (0x00007FA6F124BFAA [libj9vm29.so+0x1b0faa])
ffi_call_int+0x1fc (0x00007FA6F124A28C [libj9vm29.so+0x1af28c])
_ZN32VM_BytecodeInterpreterCompressed3runEP10J9VMThread+0x11ec9 (0x00007FA6F1140469 [libj9vm29.so+0xa5469])
bytecodeLoopCompressed+0xad (0x00007FA6F112E58D [libj9vm29.so+0x9358d])
 (0x00007FA6F11D88A2 [libj9vm29.so+0x13d8a2])

@fengxue-IS
Copy link
Contributor

the crash is expected as jvmtiGetStackTrace have not been updated to accept a VirtualThread

@thallium thallium force-pushed the jvmtiGetFrameCount branch 2 times, most recently from 4986887 to a086b7a Compare August 26, 2022 21:05
runtime/vm/intfunc.c Outdated Show resolved Hide resolved
runtime/jvmti/jvmtiStackFrame.c Outdated Show resolved Hide resolved
runtime/jvmti/jvmtiStackFrame.c Outdated Show resolved Hide resolved
@thallium
Copy link
Contributor Author

with #15788, the GetFrameCount test passed.

Copy link
Contributor

@fengxue-IS fengxue-IS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fengxue-IS
Copy link
Contributor

@thallium can you remove the WIP in heading and mark this as ready for review

@fengxue-IS
Copy link
Contributor

@hangshao0 can you take a look

@thallium thallium changed the title [WIP]Virtual threads support for jvmtiGetFrameCount Virtual threads support for jvmtiGetFrameCount Aug 29, 2022
@thallium thallium marked this pull request as ready for review August 29, 2022 19:34
@hangshao0
Copy link
Contributor

Can you update the commit message and the description here including more detailed explanation about the solution ?

@thallium
Copy link
Contributor Author

Done

@hangshao0
Copy link
Contributor

Done

Did you push the change ? I don't see any change.

@thallium
Copy link
Contributor Author

thallium commented Aug 30, 2022

Done

Did you push the change ? I don't see any change.

Sorry I thought you only want to update the PR message, but I don't see any need to update the commit message? You mean adding the message related to walkContinuationStackFrames?

@hangshao0
Copy link
Contributor

You need to update both the commit message and the description of this PR. You can look at other PRs as an example. Also I suggest to mention the issue number in both places. If there is no issue for jvmtiGetFrameCount, you can use #15183.

@thallium
Copy link
Contributor Author

Is it good now?

@hangshao0 hangshao0 added comp:vm project:loom Used to track Project Loom related work labels Aug 30, 2022
@hangshao0 hangshao0 added this to the Java 19 milestone Aug 30, 2022
@hangshao0 hangshao0 requested a review from tajila August 31, 2022 15:25
Copy link
Contributor

@tajila tajila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor comment

runtime/jvmti/jvmtiStackFrame.c Show resolved Hide resolved
j9object_t contObject = (j9object_t)J9VMJAVALANGVIRTUALTHREAD_CONT(currentThread, threadObject);
internalVMFunctions->walkContinuationStackFrames(currentThread, contObject, &walkState);
} else {
Assert_JVMTI_true(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add a new Assert_JVMTI_unreachable to j9jvmti.tdf

Adds `Assert_JVMTI_unreachable` to mark places as unreachable
Adds `walkContinuationStackFrames` to internal functions so jvmti code can use it.
Adds a check for whether it's a virtual thread and not yielded or terminated.
If it is, use `walkContinuationStackFrames` to walk the continuation object.
Issue: eclipse-openj9#15183 eclipse-openj9#15759

Signed-off-by: Gengchen Tuo <gengchen.tuo@ibm.com>
@tajila
Copy link
Contributor

tajila commented Aug 31, 2022

jenkins compile win jdk8

@tajila
Copy link
Contributor

tajila commented Aug 31, 2022

jenkins test sanity amac jdk19

@tajila
Copy link
Contributor

tajila commented Aug 31, 2022

jenkins test sanity plinux jdk19

@tajila tajila merged commit cfbfdeb into eclipse-openj9:master Sep 1, 2022
@thallium thallium deleted the jvmtiGetFrameCount branch September 1, 2022 13:02
keithc-ca added a commit to keithc-ca/openj9 that referenced this pull request Sep 1, 2022
* move new tracepoint to the end
* fix illegal C code (move declaration)

Signed-off-by: Keith W. Campbell <keithc@ca.ibm.com>
@keithc-ca
Copy link
Contributor

My concerns above are addressed by #15813.

@babsingh
Copy link
Contributor

babsingh commented Sep 1, 2022

re #15753 (comment):

@thallium Did the GetFrameCount/framecnt01 test in the above comment pass with these changes?

@thallium
Copy link
Contributor Author

thallium commented Sep 1, 2022

re #15753 (comment):

@thallium Did the GetFrameCount/framecnt01 test in the above comment pass with these changes?

It’s mostly due to getStackTrace hasn’t been updated, it passed with my PR on updating getStackTrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:vm jdk19 project:loom Used to track Project Loom related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants