Skip to content

Free pending named positions on partial-argument compile errors#185

Open
iliaal wants to merge 1 commit into
masterfrom
fix/pfa-named-positions-leak
Open

Free pending named positions on partial-argument compile errors#185
iliaal wants to merge 1 commit into
masterfrom
fix/pfa-named-positions-leak

Conversation

@iliaal

@iliaal iliaal commented Jul 18, 2026

Copy link
Copy Markdown
Owner

A partial application that uses a named placeholder (foo(x: ?, ...)) lazily allocates a named-positions table in zend_compile_args_ex, consumed only after argument compilation succeeds. A following argument that is itself a compile error (a positional or unpack after the named placeholder, or a misplaced variadic placeholder) longjmps out of the function before the table is consumed and leaks it.

This frees the table before the four reachable errors. The leak is on a zend_bailout path, so ZEND_MM's leak reporter never sees it; it shows only under valgrind/ASAN. Verified with USE_ZEND_ALLOC=0 valgrind: 376 bytes to 0 on foo(x: ?, ?), and 0 on the unpack, named-after-variadic, and variadic-twice variants. The added test exercises the path for CI valgrind; the error output is identical before and after, so it is a path check, not an output red/green.

A named placeholder in a partial application lazily allocates a
named-positions table that is only consumed once argument compilation
succeeds. A later argument that is itself a compile error (a positional
or unpack after the named placeholder, or a misplaced variadic
placeholder) longjmps out of zend_compile_args_ex before the table is
consumed, leaking it. Free the table before those errors.
@iliaal
iliaal force-pushed the fix/pfa-named-positions-leak branch from 31b7d61 to c3bd629 Compare July 18, 2026 23:49
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.

1 participant