Integrated: 8351660: C2: SIGFPE in unsigned_mod_value

Saranya Natarajan duke at openjdk.org
Thu Apr 10 08:01:38 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.

This pull request has now been integrated.

Changeset: 04e2a062
Author:    Saranya Natarajan <saranya.natarajan at oracle.com>
Committer: Damon Fenacci <dfenacci at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/04e2a0621d80f23cf70b4649ec4c24dad28e8e2d
Stats:     63 lines in 2 files changed: 63 ins; 0 del; 0 mod

8351660: C2: SIGFPE in unsigned_mod_value

Co-authored-by: Emanuel Peter <epeter at openjdk.org>
Reviewed-by: chagedorn, dfenacci, epeter

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

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


More information about the hotspot-compiler-dev mailing list