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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Jun 10 12:55:17 UTC 2021


On Wed, 9 Jun 2021 10:33:34 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> 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).

This pull request has now been integrated.

Changeset: f4b31701
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/f4b3170197ca517b4816f863af053f019ce0f181
Stats:     15 lines in 1 file changed: 6 ins; 3 del; 6 mod

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

Reviewed-by: dfuchs

-------------

PR: https://git.openjdk.java.net/jdk/pull/4427


More information about the core-libs-dev mailing list