JDK-8316417 : ObjectMonitorIterator does not return the most recent monitor and is incorrect if no monitors exists
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 22
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-09-18
  • Updated: 2023-09-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22Unresolved
Related Reports
Relates :  
Relates :  
Description
ObjectMonitorIterator fails to return the most recent monitor added. It starts 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`.
Comments
But this would have to be lack of any testing, by anyone, as this just could not work if so fundamentally flawed.
25-09-2023

Okay so this code has been broken since introduced in JDK 17, but it is never apparently used. If I understand the test correctly there are always at least 2 used monitors in a running VM and the test finds at least one and so passes - not realising it finds the second rather than the first.
25-09-2023

This code was introduced by JDK-8259008, so not that long ago in HS terms.
25-09-2023

Well, lack of a good test for one. Also, I wonder if the bug was a somewhat recent introduction. Not necessarily in the past few months, but maybe the past 2-4 years due to changes in hotspot that were not correctly handled in SA.
25-09-2023

This seems such a fundamental flaw that its existence should have been obvious. Why has this not been noticed? Why are tests not failing?
25-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15782 Date: 2023-09-18 09:54:18 +0000
18-09-2023