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

8268428: Test java/foreign/TestResourceScope.java fails: expected [M] but found [N] #4427

Closed
wants to merge 2 commits into from

Conversation

mcimadamore
Copy link
Contributor

@mcimadamore mcimadamore commented Jun 9, 2021

This tests fails intermittently but very rarely, on Windows it seems. The subtest in question is testLockSharedMultiThread. This test is spawning a number of threads, each of which:

  • increments a counter atomically
  • acquire scope
  • waits some time
  • release scope
  • decrement counter (in finally block)

The main test thread tries (while the counter value is > 0) to repeatedly close the scope, and asserts that if the scope closes successfully, then the counter value should be exactly zero.

Looking at the test closely, I realized there's an issue: the order in which counter is incremented and scope is acquired is wrong. As such it is possible for counter to be increased, but then for subsequent acquire to fail (e.g. if segment is already closed). This would lead to the main test thread to fail, as it would appear as if the segment has been closed successfully, but the counter value is not zero.

The fix is to only increment the counter after a successful acquire. I have also tweaked the test so that it keeps trying closing the scope, even if the counter value reaches zero permanently (e.g. all other threads have completed).


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8268428: Test java/foreign/TestResourceScope.java fails: expected [M] but found [N]

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4427/head:pull/4427
$ git checkout pull/4427

Update a local copy of the PR:
$ git checkout pull/4427
$ git pull https://git.openjdk.java.net/jdk pull/4427/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4427

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4427.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 9, 2021

👋 Welcome back mcimadamore! 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 openjdk bot added the rfr Pull request is ready for review label Jun 9, 2021
@openjdk
Copy link

openjdk bot commented Jun 9, 2021

@mcimadamore 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 9, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 9, 2021

Webrevs

Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

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

I agree with the analysis and test code changes. Trivially you should also update the copyright years on this file.

@openjdk
Copy link

openjdk bot commented Jun 9, 2021

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

8268428: Test java/foreign/TestResourceScope.java fails: expected [M] but found [N]

Reviewed-by: dfuchs

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 86 new commits pushed to the master branch:

  • dd34a4c: 8268372: ZGC: dynamically select the number of concurrent GC threads used
  • 4388959: 8268056: Update java.net and java.nio to use switch expressions
  • 9cfd560: 8267663: [vector] Add unsigned comparison operators on AArch64
  • 4413142: 8268017: C2: assert(phi_type->isa_int() || phi_type->isa_ptr() || phi_type->isa_long()) failed: bad phi type
  • 2bfd708: 8266557: assert(SafepointMechanism::local_poll_armed(_handshakee)) failed: Must be
  • 4d1cf51: 8240349: jlink should not leave partial image output directory on failure
  • 07108c9: 8268241: deprecate JVM TI Heap functions 1.0
  • c9dbc4f: 8266891: Provide a switch to force the class space to a specific location
  • 2cc1977: 8268424: JFR tests fail due to GC cause 'G1 Preventive Collection' not in the valid causes after JDK-8257774
  • 58a59e3: 8240997: Remove more "hack" word in security codes
  • ... and 76 more: https://git.openjdk.java.net/jdk/compare/3025f05970ede82c6f67a0434e33b27205e10130...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this 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 9, 2021
@mcimadamore
Copy link
Contributor Author

/integrate

@openjdk openjdk bot closed this Jun 10, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 10, 2021
@openjdk
Copy link

openjdk bot commented Jun 10, 2021

@mcimadamore Since your change was applied there have been 124 commits pushed to the master branch:

  • 6b6ff53: 8268543: some runtime/verifier tests should be run in driver mode
  • 0924382: 8266766: Arrays of types that cannot be an annotation member do not yield exceptions
  • d43c8a7: 8268124: Update java.lang to use switch expressions
  • a187fcc: 8238197: JFR: Rework setting and getting EventHandler
  • f770f77: 8268390: G1 concurrent gc upgrade to full gc not working
  • e0c0b13: 8268534: some serviceability/jvmti tests should be run in driver mode
  • 92f0b6d: 8268532: several serviceability/attach tests should be run in driver mode
  • 964118f: 8268538: mark hotspot serviceability/logging tests which ignore external VM flags
  • 05090fc: 8268536: mark hotspot serviceability/dcmd tests which ignore external VM flags
  • ae29f9c: 8268530: resourcehogs/serviceability/jvmti/GetObjectSizeOverflow.java should be run in driver mode
  • ... and 114 more: https://git.openjdk.java.net/jdk/compare/3025f05970ede82c6f67a0434e33b27205e10130...master

Your commit was automatically rebased without conflicts.

Pushed as commit f4b3170.

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

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