RFR: 8332506: SIGFPE In ObjectSynchronizer::is_async_deflation_needed() [v3]

David Holmes dholmes at openjdk.org
Tue Jan 7 00:46:41 UTC 2025


On Mon, 6 Jan 2025 19:15:28 GMT, Fredrik Bredberg <fbredberg at openjdk.org> wrote:

>> src/hotspot/share/runtime/synchronizer.cpp line 1274:
>> 
>>> 1272:   // Make sure the we use a ceiling value that is not lower than the
>>> 1273:   // max used by the system, and not zero.
>>> 1274:   size_t ceiling = MAX3(old_ceiling, list->max(), monitors_used);
>> 
>> The comment does not explain why these three components are checked.
>
> If `list->max()` is above `old_ceiling` we should use that because the number of actual used monitors, has at one point exceeded the `old_ceiling` value. Why add `monitors_used` to the mix? Any increase in the `list->max()` value will come  **after** the increase in `list->count()` aka `monitors_used`. So by adding `monitors_used` to the mix we ensure that `ceiling` can't become zero, even if `old_ceiling` is zero and `list->max()` hasn't been increased yet. Because we [know](https://github.com/openjdk/jdk/blob/502766b759d13edd1ce3f4ebd46fcc8f13ed5d53/src/hotspot/share/runtime/synchronizer.cpp#L1268) that `monitors_used` is not zero.
> 
> I tried to condense that into a shorter comment, but obviously I failed.

But `monitors_used == list->count()` and `list->count()` by definition must be <= `list->max()`, so including `monitors_used` in the `MAX3` expression is pointless.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22815#discussion_r1904778611


More information about the hotspot-runtime-dev mailing list