RFR: 8351660: C2: SIGFPE in unsigned_mod_value

Damon Fenacci dfenacci at openjdk.org
Tue Apr 8 13:15:50 UTC 2025


On Thu, 3 Apr 2025 10:29: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.

Thanks for the fix @sarannat!

Do you think we could add the failing test as regression test (maybe in the already available Mod tests, without creating a new test file)?

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

PR Comment: https://git.openjdk.org/jdk/pull/24410#issuecomment-2778046700


More information about the hotspot-compiler-dev mailing list