RFR: 8351660: C2: SIGFPE in unsigned_mod_value [v5]

Christian Hagedorn chagedorn at openjdk.org
Wed Apr 9 08:54:57 UTC 2025


On Wed, 9 Apr 2025 08:50:08 GMT, Saranya Natarajan <duke at openjdk.org> wrote:

>> Description :: The test program performs a`Long.remainderUnsigned` which triggers the call to the function `unsigned_mod_value`. At the end of `unsigned_mod_value` the expression,` return TypeClass::make(static_cast<Signed>(dividend % divisor))`, is computed which leads to a SIGFPE as the divisor in the test program is zero. The same behaviour was observed when the ` Long.remainderUnsigned` was replaced with `Integer.remainderUnsigned` in the test program. 
>> 
>> Solution :: The fix for [JDK-8345766](https://bugs.openjdk.org/browse/JDK-8345766) emitted specific ModF/ModD nodes, which is optimized and converted to runtime calls after optimizations. This was done during parsing prior to [JDK-8345766](https://bugs.openjdk.org/browse/JDK-8345766).  In the scenario where there was unsigned modulo operation as in this test, there was no check for modulo by zero that could trigger an exception during runtime. The below fix proposes a check for modulo by zero and throws exception at runtime.
>> 
>> A Jtreg test has been added as part of this fix. This test case is based on the original test that resulted in the bug. @eme64 is the contributor of the original test. Thank you @eme64.
>
> Saranya Natarajan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   correcting comments in included test

Marked as reviewed by chagedorn (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/24410#pullrequestreview-2752619842


More information about the hotspot-compiler-dev mailing list