Skip to content

Fix GH-22549: GMP compound pow/shift assign asserts on negative operand#145

Closed
iliaal wants to merge 1 commit into
masterfrom
fix/gh-22549-gmp-shift-undef
Closed

Fix GH-22549: GMP compound pow/shift assign asserts on negative operand#145
iliaal wants to merge 1 commit into
masterfrom
fix/gh-22549-gmp-shift-undef

Conversation

@iliaal

@iliaal iliaal commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Removes a stray ZVAL_UNDEF(return_value) in GMP's shift_operator_helper() that clobbered op1 on a compound $x **= gmp_init(-5) (where result aliases op1), making pow_function's fall-through assert on an IS_UNDEF operand. Affects POW/SL/SR; the other failure paths already return without touching return_value.

Fixes php#22549

…erand

shift_operator_helper() wrote ZVAL_UNDEF(return_value) on the out-of-range
exponent/shift path, but for a compound assignment return_value aliases op1,
so pow_function's fallback then reached the scalar conversion with op1 set to
IS_UNDEF and hit ZEND_UNREACHABLE(). Drop the stray undef; the helper's other
error paths already return FAILURE without touching return_value, leaving the
operand intact for the thrown ValueError to propagate.

Fixes phpGH-22549
@iliaal

iliaal commented Jul 3, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream: php#22582

@iliaal iliaal closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assertion failure _zendi_try_convert_scalar_to_number

1 participant