Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
/ jdk19 Public archive

8289079: java/lang/Thread/jni/AttachCurrentThread/AttachTest.java#id1 failed with "RuntimeException: Test failed" #73

Closed
wants to merge 1 commit into from

Conversation

AlanBateman
Copy link

@AlanBateman AlanBateman commented Jun 26, 2022

This is a fix to a recently added test. The test uses pthread_create to create native threads that invoke a Java method via a generated "upcall stub". The upcall stub is created in an implicit memory session but the test doesn't do anything to ensure that the memory session remains open. Testing in higher tiers runs the test with options that sometimes lead to a cleaner closing the memory session before the native threads have terminated. The failure mode is exit code 133 due to a child VM exiting with SIGTRAP. The test needs to be changed to ensure that the memory session is not closed until the threads terminate. To keep it simple, I've changed it to use the global memory session. The alternative is to change it to use a shared session or a reachability fence, coupled with a pthread_join to ensure that all native threads with a reference to stub terminate before the session is closed. The test is intended to exercise concurrent implicit attaching so keeping it as simple as possible seems best.

The test is also changed too use shouldHaveExitValue(0) as the original test discarded the child VM exit code when the test failed.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8289079: java/lang/Thread/jni/AttachCurrentThread/AttachTest.java#id1 failed with "RuntimeException: Test failed"

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk19 pull/73/head:pull/73
$ git checkout pull/73

Update a local copy of the PR:
$ git checkout pull/73
$ git pull https://git.openjdk.org/jdk19 pull/73/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 73

View PR using the GUI difftool:
$ git pr show -t 73

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk19/pull/73.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 26, 2022

👋 Welcome back alanb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jun 26, 2022

@AlanBateman The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Jun 26, 2022
@AlanBateman AlanBateman marked this pull request as ready for review June 26, 2022 10:33
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 26, 2022
@mlbridge
Copy link

mlbridge bot commented Jun 26, 2022

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Explanation and fix seem quite reasonable.

Thanks.

@openjdk
Copy link

openjdk bot commented Jun 27, 2022

@AlanBateman 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:

8289079: java/lang/Thread/jni/AttachCurrentThread/AttachTest.java#id1 failed with "RuntimeException: Test failed"

Reviewed-by: dholmes, mcimadamore

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 master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 27, 2022
@mcimadamore
Copy link
Contributor

For the records - the implicit upcall will be kept alive for the duration of the downcall to which it is passed to. In this case, since the downcall forks another thread and then returns (and the call to the stub occurs at some point later in the other thread), it is possible for the implicit session to be reclaimed before the async thread had a chance to execute it. With fully synchronous code this would never be an issue, as the standard safety "keep-alive" provided by the linker would have been enough.

@AlanBateman
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 27, 2022

Going to push as commit 7e13cdb.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 27, 2022
@openjdk openjdk bot closed this Jun 27, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 27, 2022
@openjdk
Copy link

openjdk bot commented Jun 27, 2022

@AlanBateman Pushed as commit 7e13cdb.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants