Skip to content

Assert zend_call_method instance call contract - #25504

Open
kairosci wants to merge 1 commit into
php:masterfrom
kairosci:fix/gh-25405-zend-call-method-assert
Open

kairosci wants to merge 1 commit into
php:masterfrom
kairosci:fix/gh-25405-zend-call-method-assert

Conversation

@kairosci

@kairosci kairosci commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Refs #25405.

zend_call_method() requires a non-NULL object when invoking an instance method. Add a ZEND_ASSERT after resolving the target function so debug builds catch violations at the API boundary. Keep the zend_test wrapper as a direct pass-through to the C API, and update the static-return test to pass objects to instance methods.

Verified in a debug build: each reported invalid call (returnTrue, returnsRef, returnsProp, and callsMethod) stops at the assertion. Calls with an object and calls to static methods succeed. The static-return PHPT passes.

@kairosci
kairosci marked this pull request as draft November 16, 2026 21:53
@kairosci kairosci changed the title Add assertion for zend_call_method object Fix GH-25405: Reject invalid zend_test method calls Nov 16, 2026
@kairosci
kairosci marked this pull request as ready for review November 16, 2026 21:56
@kairosci
kairosci force-pushed the fix/gh-25405-zend-call-method-assert branch 3 times, most recently from 7045637 to 662199b Compare November 16, 2026 22:00
@kairosci kairosci changed the title Fix GH-25405: Reject invalid zend_test method calls Reject invalid zend_test zend_call_method calls Nov 16, 2026
@kairosci

Copy link
Copy Markdown
Contributor Author

@DanielEScherzer @Girgias as soon as you can, could you take a look at it? Thanks!

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A: taking over someone else's PR that is only 5 days old is frankly disrespectful.

B: this utterly misses the point of adding an assertion, zend_test is an extension that exists to test aspect of the Zend engine/expose functionality that is not easily accessible. Fixing the implementation of a test function is pointless.

@kairosci
kairosci force-pushed the fix/gh-25405-zend-call-method-assert branch from 662199b to f9652f0 Compare November 17, 2026 00:30
Add a debug assertion to catch calls to instance methods without an object. Keep zend_test as a direct wrapper around the C API and pass objects to instance methods in the static return test.

Refs php#25405.
@kairosci
kairosci force-pushed the fix/gh-25405-zend-call-method-assert branch from f9652f0 to 66fc191 Compare November 17, 2026 00:30
@kairosci kairosci changed the title Reject invalid zend_test zend_call_method calls Assert zend_call_method instance call contract Nov 17, 2026
@kairosci

Copy link
Copy Markdown
Contributor Author

Sorry for opening a parallel PR without coordinating first. I’ve removed the wrapper fix and kept only the assertion.

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.

2 participants