RFR: 8351660: C2: SIGFPE in unsigned_mod_value

Saranya Natarajan duke at openjdk.org
Thu Apr 3 20:11:08 UTC 2025


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`,` 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, there was no check for modulo by zero.  The fix proposed checks if there is modulo by zero and throws exception at runtime.

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

Commit messages:
 - JDK-8351660: C2: SIGFPE in unsigned_mod_value

Changes: https://git.openjdk.org/jdk/pull/24410/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24410&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8351660
  Stats: 5 lines in 1 file changed: 5 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/24410.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24410/head:pull/24410

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


More information about the hotspot-compiler-dev mailing list