Free previous state when re-calling Reflection*::__construct() - #22968
Closed
iliaal wants to merge 1 commit into
Closed
Free previous state when re-calling Reflection*::__construct()#22968iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
iliaal
added a commit
to iliaal/php-src
that referenced
this pull request
Jul 31, 2026
ReflectionMethod::__construct() overwrote intern->ptr without releasing the previous Closure::__invoke() trampoline, and ReflectionClassConstant::__construct() overwrote the $name and $class slots without dropping their previous references. ReflectionFunction, ReflectionParameter and ReflectionProperty already release prior state on re-entry. Closes phpGH-22968
iliaal
force-pushed
the
fix/reflection-method-reconstruct-leak
branch
from
July 31, 2026 13:27
cd9d932 to
e3a79ed
Compare
DanielEScherzer
approved these changes
Jul 31, 2026
DanielEScherzer
left a comment
Member
There was a problem hiding this comment.
makes sense to me, one suggestion for clarity
ReflectionMethod::__construct() overwrote intern->ptr without releasing the previous Closure::__invoke() trampoline, and ReflectionClassConstant::__construct() overwrote the $name and $class slots without dropping their previous references. ReflectionFunction, ReflectionParameter and ReflectionProperty already release prior state on re-entry. Closes phpGH-22968
iliaal
force-pushed
the
fix/reflection-method-reconstruct-leak
branch
from
July 31, 2026 14:51
e3a79ed to
8e7ecbf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ReflectionMethod::__construct()overwrites intern->ptr without releasing the previous value. When the reflected method is Closure::__invoke() that value is a trampoline allocated byzend_get_closure_invoke_method(), so every re-construct leaks one. ReflectionClassConstant::__construct() has the same shape for the $name and $class property slots and leaks a string reference whenever the constant name is not interned. ReflectionFunction, ReflectionParameter and ReflectionProperty already release prior state on re-entry.