On Wed, 9 Jun 2021 11:31:52 GMT, Maurizio Cimadamore <mcimadam...@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).
>
> Maurizio Cimadamore has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Update wrong copyright date

Marked as reviewed by dfuchs (Reviewer).

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

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

Reply via email to