RFR: 8262197: JDK-8242032 uses wrong contains_reference() in assertion code

Thomas Schatzl tschatzl at openjdk.java.net
Tue Feb 23 15:57:41 UTC 2021


On Tue, 23 Feb 2021 15:25:56 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

>> Hi all,
>> 
>>   can I have reviews for this change that fixes use of the wrong HeapRegionRemSet::contains_reference() method, causing a thread lock the same mutex again, resulting in problems like assertion failures?
>> 
>> The code in question has been introduced in JDK-8242032:
>> 
>> 
>>     +    // Rechecking if the region is coarsened, while holding the lock.
>>     +    if (is_region_coarsened(from_hrm_ind)) {
>>     +      assert(contains_reference(from), "We just found " PTR_FORMAT " in the Coarse table", p2i(from));
>>     +      return;
>>     +    }
>> 
>> The problem is the call to `contains_reference`, which locks the same lock that "we know we are already locking" per the comment above. Correct is using `contains_reference_locked` added for just this purpose.
>> 
>> In the original change the PR already mentioned that the situation where this condition should hold could not be reproduced - now we know that it actually occurs ;) 
>> 
>> Testing: tier1. Trying to reproduce with the original some of the failing tests without luck - however the problematic line and the fix is very obvious.
>> 
>> Thanks,
>>   Thomas
>
> Marked as reviewed by ayang (Author).

Thanks @albertnetymk @kimbarrett for the reviews.

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

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



More information about the hotspot-gc-dev mailing list