RFR: 8332506: SIGFPE In ObjectSynchronizer::is_async_deflation_needed()

David Holmes dholmes at openjdk.org
Thu Dec 19 23:01:43 UTC 2024


On Thu, 19 Dec 2024 12:32:29 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> src/hotspot/share/runtime/synchronizer.cpp line 1281:
>> 
>>> 1279:       _no_progress_cnt >= NoAsyncDeflationProgressMax) {
>>> 1280:     double remainder = (100.0 - MonitorUsedDeflationThreshold) / 100.0;
>>> 1281:     size_t new_ceiling = ceiling + (size_t)((double)ceiling * remainder) + 1;
>> 
>> if you are looking fort the minimal fix for the division-by-zero problem, then I think simply fixing this line to avoid overflow will suffice:
>> 
>> size_t delta = (size_t)(ceiling * remainder) + 1;
>> if (ceiling > SIZE_MAX - delta) { // overflow
>>   ceiling = SIZE_MAX;  // Or some other positive limit
>> } else {
>>   ceiling += delta;
>> }
>
> I think this code with the introduction of delta looks a bit more clear to me, if you use it in your existing patch to replace lines 1286 to 1289.  That would still be a minimal fix.

It is the only thing needed to fix the overflow. Anything else should be deferred to a later "fixing the math" issue IMO.

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

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


More information about the hotspot-runtime-dev mailing list