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

Fredrik Bredberg fbredberg at openjdk.org
Thu Jan 2 14:43:22 UTC 2025


> This PR solves a division by zero problem, that according to the bug report happened in `ObjectSynchronizer::is_async_deflation_needed()`. As it turns out it really happened in the inlined  `monitors_used_above_threshold()` function. The problematic line looked like this:
> 
> `size_t monitor_usage = (monitors_used * 100LL) / ceiling;`
> 
> Unfortunately the `ceiling` value was increased every time there where too many deflations without any progress. This whould eventually lead to an overflow in the `ceiling` value, and in unlucky circumstances, it would become zero. Thus causing a division by zero crash.
> 
> This PR makes sure not to increase the `ceiling` value if `monitor_usage` is below the `MonitorUsedDeflationThreshold`.
> It also makes sure the ceiling value is never zero, and does not wrap around.
> 
> Tested okay in tier1-5 and `test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java`

Fredrik Bredberg has updated the pull request incrementally with one additional commit since the last revision:

  Update after review

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/22815/files
  - new: https://git.openjdk.org/jdk/pull/22815/files/16c3fecd..452fb584

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=22815&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=22815&range=00-01

  Stats: 9 lines in 1 file changed: 3 ins; 3 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/22815.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22815/head:pull/22815

PR: https://git.openjdk.org/jdk/pull/22815


More information about the hotspot-runtime-dev mailing list