RFR: 8316417: ObjectMonitorIterator does not return the most recent monitor and is incorrect if no monitors exists [v5]

Chris Plummer cjplummer at openjdk.org
Wed Sep 20 22:40:41 UTC 2023


On Tue, 19 Sep 2023 09:25:33 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

>> ObjectMonitorIterator fails to return the most resent monitor added. It start with returning the `nextOM()` ObjectMonitor from the `_head` ObjectMonitor but fails to ever return the `_head` ObjectMonitor.
>> The current implementation can also not handle that the `_head` is nullptr (no monitors in the system) and returns a null ObjectMonitorIterator. Which is interpreted as `monitor list not supported, too old hotspot VM`.
>> 
>> Changed the iterator to keep return the current monitor (starts with `_head`) and decoupled `_head == nullptr` from the question if ObjectMonitorIterator is supported. 
>> 
>> Testing:
>>   * Passes all `serviceability/sa` tests
>>   * Passed tier 1-5
>>   * Passed GHA
>
> Axel Boldt-Christmas has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Removed unnecessary comment

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ObjectSynchronizer.java line 86:

> 84: 
> 85:     ObjectMonitorIterator() {
> 86:       mon = new ObjectMonitor(inUseList);

How did this ever work? `inUseList` is an address that points to a `MonitorList`, not an `ObjectMonitor`. Your new code has it right, but it seems that this old code would have failed either during construction, or during the first `mon.nextOM()` call.

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicSharedSymbols.java line 41:

> 39:  * @build jdk.test.whitebox.WhiteBox
> 40:  * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar loadclass.jar JCmdTestLingeredApp
> 41:  *             jdk.test.lib.apps.LingeredApp jdk.test.lib.apps.LingeredApp$1 jdk.test.lib.apps.LingeredApp$SteadyStateLock

Copyright needs updating in this file.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15782#discussion_r1332246787
PR Review Comment: https://git.openjdk.org/jdk/pull/15782#discussion_r1330761695


More information about the serviceability-dev mailing list