Fixed bug #61998 (Crash when declare trait after class if user define the same name as aliased one)#83
Fixed bug #61998 (Crash when declare trait after class if user define the same name as aliased one)#83reeze wants to merge 2 commits intophp:PHP-5.4from
Conversation
|
@laruence thanks I will update that later. It used to add a null to the start of the key to get a special key can't be accessed by user. the tmp_fn_name was emalloced with an additional byte to hold it. |
…d the same method as aliased one)
|
On Tue, May 15, 2012 at 12:30 PM, Reeze Xia
thanks for your working on it. it is appreciated. However, the trick way should not be encouraged, and after deeply look thanks
|
|
Hi: my patch was attached here: thanks On Wed, May 16, 2012 at 2:24 PM, Account for PHP Pull Requests
|
|
Add extra function to function_table is not that perfect.@laruence 's patch looks better. |
- Added ZEND_ASYNC_IO_TYPE_TCP and ZEND_ASYNC_IO_TYPE_UDP types - Modified zend_async_io_s to use union for fd/socket descriptor - Added zend_async_udp_req_s structure for UDP operations - Added socket options enum (broadcast, multicast, TCP options) - Extended zend_async_io_register() with UDP and socket option functions - Added includes for socket types (sys/socket.h, winsock2.h)
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";
}
}