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

Fredrik Bredberg fbredberg at openjdk.org
Fri Dec 20 13:28:37 UTC 2024


On Thu, 19 Dec 2024 22:58:50 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> 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.

What's more clear to some people, might be more unclear to some other people (like me).

To me it's clear that we have an overflow after adding two unsigned numbers A and B, if the result is less than any of the numbers A and B. A quick search on the interwebs also confirms this. So, in this case if `new_ceiling < old_ceiling` we have an overflow.

Looking at the suggested:


size_t delta = (size_t)(ceiling * remainder) + 1;
if (ceiling > SIZE_MAX - delta) { // overflow


I see "if ceiling is larger than the largest possible number minus some delta (which might be very small), we have and overflow" and I think, this might be true... Not saying you are wrong, but it's definitely not clear to me by just looking at it.

Definitely agree that we should fix the math that calculates the `new_ceiling` later.

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

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


More information about the hotspot-runtime-dev mailing list