Fixed bug #61998 (Crash when declare trait after class if user define the same name as aliased one) #83
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.
Thanks ron for your test script. I've make a minimal reproducible one below:
In class Class1:
In trait T
--- since class was destroyed by reverse order --
the Class1 referred to this function.
function name was referred to it.(this let riginal function name
in trait unreleased and leak).
after destroy function table it will destroy alias info. but alias name was
already destroyed in function table releasing phrase. This cause double free(crash).
Solutions:
but it will make reflection unhappy and can't throw right error message for function.
This need to change reflection ignore it.get_defined_functions() & get_delcared_clesses()
use this trick to filter special entry. so we need to change ReflectionClass::getMethods().
in summary I prefer option 3. What do you think?
public function func() { // <------------ if this override trait method and the method get aliased will lead crash
echo "From Class1::func\n";
}
}
class Class2 {
use T;
}
trait T { // <------------------------------ declare after the Class1 and it will be destroy before Class1
public function func() {
echo "From trait T\n";
}
}