RFR: 8268428: Test java/foreign/TestResourceScope.java fails: expected [M] but found [N] [v2]
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Wed Jun 9 11:34:33 UTC 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).
Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
Update wrong copyright date
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/4427/files
- new: https://git.openjdk.java.net/jdk/pull/4427/files/eb0c5d50..13f87671
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4427&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4427&range=00-01
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/4427.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/4427/head:pull/4427
PR: https://git.openjdk.java.net/jdk/pull/4427
More information about the core-libs-dev
mailing list