On Tue, 14 Jul 2026 07:24:36 GMT, Serguei Spitsyn <[email protected]> wrote:

>> This update fixes the test bug which was initially filed as a Valhalla bug 
>> but then found to be NOT Valhalla specific.
>> The static variable `objectCount` is used for two different purposes:
>>  - to count current walked objects number
>>  - as a number to tag objects
>> 
>> This leads to mismatches in indexes calculations.
>> For instance the `ObjectFree` event callback decrements the `objectCount` 
>> number. Then the `objectCountMax` can be smaller than some of the actual 
>> indexes.
>> The fix does:
>>  - adds a fragment to force GC's with the JVMTI `ForceGarbageCollection` to 
>> make the failure well reproducible
>>  - split `objectCount` into: `objectCount` and `objectTagCount`
>>  - `objectTagCount` is used to set the object tags and value of the 
>> `objectCountMax`
>>  - a couple of the `ind` boundary checks are also corrected
>> 
>> Testing:
>>  - Executed the test locally: 
>> `jvmti/IterateOverReachableObjects/iterreachobj002`
>>  - TBD: Submit mach5 tiers 1-3 to be safe
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Serguei Spitsyn has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   review: removed objectCount var, ObjectFree event callback and related 
> capability

test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj002/iterreachobj002.cpp
 line 322:

> 320: 
> 321:             /* Deallocate last unnecessary descriptor */
> 322:             if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned 
> char*)objectDescList))) {

This is a bit odd in that now the next field of the last initialized 
ObjectDescStruct in the list points to de-allocated memory. This doesn't cause 
issues because we don't use a NULL next pointer to indicate reaching the end of 
the list. We always walk objectCountMax entries. Maybe it would be better to do 
this Dealloc after initializing objectDescArr below, and at the same time also 
assert that objectDescList->next->next is NULL. Maybe a cleanup for another day.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31585#discussion_r3596744435

Reply via email to