Skip to content

Fix GH-17307: Internal closure causes JIT failure#17319

Closed
ndossche wants to merge 1 commit intophp:PHP-8.4from
ndossche:fix-17307
Closed

Fix GH-17307: Internal closure causes JIT failure#17319
ndossche wants to merge 1 commit intophp:PHP-8.4from
ndossche:fix-17307

Conversation

@ndossche
Copy link
Copy Markdown
Member

@ndossche ndossche commented Jan 1, 2025

bcadd(...) is a closure for an internal function, and zend_jit_push_call_frame takes into account both last_var and the difference in argument numbers not only for user code but also for internal code. However, this is inconsistent with
zend_vm_calc_used_stack, causing argument corruption. Making this consistent fixes the issue.

I could only reproduce the assertion failure when using Valgrind.

This needs a backport to 8.3, which I can do if this is right.

@ndossche ndossche linked an issue Jan 1, 2025 that may be closed by this pull request
`bcadd(...)` is a closure for an internal function, and
`zend_jit_push_call_frame` takes into account both last_var and the
difference in argument numbers not only for user code but also for
internal code. However, this is inconsistent with
`zend_vm_calc_used_stack`, causing argument corruption.
Making this consistent fixes the issue.

I could only reproduce the assertion failure when using Valgrind.
@ndossche ndossche marked this pull request as ready for review January 1, 2025 22:33
@ndossche ndossche requested a review from dstogov as a code owner January 1, 2025 22:33
Copy link
Copy Markdown
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the code was originally written when we didn't have internal closures yet.
You fix looks right. Thanks!

@ndossche ndossche closed this in 28b448a Jan 9, 2025
ndossche added a commit to ndossche/php-src that referenced this pull request Jan 9, 2025
This is a backport of phpGH-17319 to fix phpGH-17307 on lower branches.
@ndossche ndossche mentioned this pull request Jan 9, 2025
ndossche added a commit to ndossche/php-src that referenced this pull request Jan 9, 2025
This is a backport of phpGH-17319 to fix phpGH-17307 on lower branches.
ndossche added a commit that referenced this pull request Jan 10, 2025
This is a backport of GH-17319 to fix GH-17307 on lower branches.

Closes GH-17424.
charmitro pushed a commit to wasix-org/php that referenced this pull request Mar 13, 2025
This is a backport of phpGH-17319 to fix phpGH-17307 on lower branches.

Closes phpGH-17424.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal closure causes JIT failure

2 participants