-
Notifications
You must be signed in to change notification settings - Fork 63
8284072: foreign/StdLibTest.java randomly crashes on MacOS/AArch64 #674
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
Conversation
This test fails intermittently on Apple silicon macOS with a JVM SIGBUS and the stack trace below: Stack: [0x0000000171758000,0x000000017195b000], sp=0x0000000171957ef0, free space=2047k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.dylib+0x984f70] MarkActivationClosure::do_code_blob(CodeBlob*)+0x3c V [libjvm.dylib+0x9bfb60] JavaThread::nmethods_do(CodeBlobClosure*)+0xac V [libjvm.dylib+0x4669a8] HandshakeState::process_by_self(bool)+0x31c V [libjvm.dylib+0x891230] SafepointMechanism::process(JavaThread*, bool)+0xac V [libjvm.dylib+0x9f4df0] UpcallLinker::on_entry(UpcallStub::FrameData*)+0xe0 v blob 0x000000010e1ca4a8 C [libsystem_c.dylib+0x5c284] _isort+0x88 C 0x176d80010e0ca444 j java.lang.invoke.LambdaForm$MH+0x0000000800c82000.invoke(Ljava/lang/Object;JJJJJ)V+16 java.base@19-internal In UpcallLinker::on_entry we call ThreadStateTransition::transition_from_native() which needs the code cache to be writable if it suspends for a safepoint/handshake. Use the ThreadWXEnable helper to temporarily set the W^X state to W while inside on_entry() and then toggle it back to X before returning to the upcall stub. Tested jdk_foreign plus looped java/foreign/StdLibTest.java for several hours on an M1 Mac Mini which used to eventually fail.
👋 Welcome back ngasson! A progress list of the required criteria for merging this PR into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this, Nick!
@nick-arm This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
Thanks @JornVernee. Just to confirm: foreign-preview is the right target branch? |
|
@@ -72,6 +72,10 @@ JavaThread* UpcallLinker::on_entry(UpcallStub::FrameData* context) { | |||
// clear any pending exception in thread (native calls start with no exception pending) | |||
thread->clear_pending_exception(); | |||
|
|||
// The call to transition_from_native below contains a safepoint check | |||
// which needs the code cache to be writable. | |||
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, thread)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naive question: should we switch back to non-writeable after the transition? E.g. I get that this probably is reverted at the end of this function - I guess I'm asking if it's ok to keep it writeable for longer than we should/need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That happens when the wx
variable goes out of scope: ThreadWXEnable
is a RAII object which saves the previous mode in its constructor and then restores in the destructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it doesn't matter that it's writable longer than strictly necessary, as long as we make it executable again before returning to the stub. We enable the W mode around the whole body of other VM entries - e.g. see VM_LEAF_BASE
in interfaceSupport.inline.hpp
.
@nick-arm
After this PR is integrated, I will pull the commit into the PR I have here: openjdk/jdk#7959 and then I'll probably mark that ready for review. |
/integrate |
Going to push as commit 2ca24e3. |
This test fails intermittently on Apple silicon macOS with a JVM SIGBUS and the stack trace below:
In
UpcallLinker::on_entry
we callThreadStateTransition::transition_from_native()
which needs the code cache to be writable if it suspends for a safepoint/handshake.Use the ThreadWXEnable helper to temporarily set the W^X state to W while inside
on_entry()
and then toggle it back to X before returning to the upcall stub.Tested
jdk_foreign
plus loopedjava/foreign/StdLibTest.java
for several hours on an M1 Mac Mini which used to eventually fail.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/panama-foreign pull/674/head:pull/674
$ git checkout pull/674
Update a local copy of the PR:
$ git checkout pull/674
$ git pull https://git.openjdk.java.net/panama-foreign pull/674/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 674
View PR using the GUI difftool:
$ git pr show -t 674
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/panama-foreign/pull/674.diff