Commit fe6a0ef59dd for php

commit fe6a0ef59dd5585b83ae21ffb88997d278e9de23
Author: waroad <dohanam2@illinois.edu>
Date:   Sat Oct 17 19:02:32 2026 -0500

    JIT: Fix SIGFPE on LONG_MIN % -1 with a constant divisor

    Assisted-by: Claude

    Closes GH-24394.

diff --git a/NEWS b/NEWS
index aa752e0af38..fea07475b6d 100644
--- a/NEWS
+++ b/NEWS
@@ -70,6 +70,7 @@ PHP                                                                        NEWS
     SCCP is disabled). (Lazizbek Ergashev)
   . Fixed bug GH-24337 (JIT: segfault when decrementing a non-numeric string
     property). (Lazizbek Ergashev)
+  . Fix SIGFPE on LONG_MIN % -1 with a constant divisor. (waroad)

 - PDO:
   . Fixed a duplicate warning when ATTR_STATEMENT_CLASS is rejected on a
diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index 92a068dbfac..8111c18f9c1 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -5926,6 +5926,9 @@ static int zend_jit_long_math_helper(zend_jit_ctx   *jit,
 				if (Z_MODE(res_addr) == IS_REG) {
 					ref = ir_CONST_LONG(0); // dead code
 				}
+			} else if (op2_lval == -1) {
+				/* Prevent overflow error/crash if op1 == LONG_MIN */
+				ref = ir_CONST_LONG(0);
 			} else if (zend_long_is_power_of_two(op2_lval) && op1_range && op1_range->min >= 0) {
 				ref = ir_AND_L(jit_Z_LVAL(jit, op1_addr), ir_CONST_LONG(op2_lval - 1));
 			} else {
diff --git a/ext/opcache/tests/jit/mod_002.phpt b/ext/opcache/tests/jit/mod_002.phpt
index b1d163b94d5..10dcae8440b 100644
--- a/ext/opcache/tests/jit/mod_002.phpt
+++ b/ext/opcache/tests/jit/mod_002.phpt
@@ -32,6 +32,7 @@ function mod0(int $a) {
 var_dump(modNeg33(-125));
 try {
     var_dump(modNeg1(125));
+    var_dump(modNeg1(PHP_INT_MIN));
 } catch (Throwable $e) {
     echo "Exception " . $e->getMessage() . "\n";
 }
@@ -49,4 +50,5 @@ function mod0(int $a) {
 int(26)
 int(-26)
 int(0)
+int(0)
 Exception (DivisionByZeroError): Modulo by zero