lisachenko / z-engine

:zap: PHP Engine Direct API
MIT License
448 stars 22 forks source link

[Bug] Method ReflectionClass->addMethod is not compatible with opcache #41

Open lisachenko opened 4 years ago

lisachenko commented 4 years ago

With enabled opcache, function redefinition doesn't work:

1) ZEngine\Reflection\ReflectionFunctionTest::testRedefine
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'Yes'
+'Test'

~/z-engine/tests/Reflection/ReflectionFunctionTest.php:84

Also, there is an assertion error:

~/src/php-src/Zend/zend_opcode.c:134: zend_function_dtor: Assertion `function->type == 1' failed.

After that PHP is crashing during request shutdown:

Program received signal SIGABRT, Aborted.
0x00007ffff5acc428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff5acc428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff5ace02a in __GI_abort () at abort.c:89
#2  0x00007ffff5ac4bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x123b8b7 "function->type == 1",
    file=file@entry=0x123b860 "~/src/php-src/Zend/zend_opcode.c", line=line@entry=134, function=function@entry=0x123c820 <__PRETTY_FUNCTION__.11912> "zend_function_dtor")
    at assert.c:92
#3  0x00007ffff5ac4c82 in __GI___assert_fail (assertion=0x123b8b7 "function->type == 1", file=0x123b860 "~/src/php-src/Zend/zend_opcode.c", line=134,
    function=0x123c820 <__PRETTY_FUNCTION__.11912> "zend_function_dtor") at assert.c:101
#4  0x00000000008e91aa in zend_function_dtor (zv=0x7ffff2a63f60) at ~/src/php-src/Zend/zend_opcode.c:134
#5  0x0000000000914c79 in zend_hash_destroy (ht=0x7ffff2bb3800) at ~/src/php-src/Zend/zend_hash.c:1541
#6  0x00000000008e9ebe in destroy_zend_class (zv=0x1811a60) at ~/src/php-src/Zend/zend_opcode.c:313
#7  0x00000000008e44bd in shutdown_executor () at ~/src/php-src/Zend/zend_execute_API.c:393
#8  0x00000000008fc8b6 in zend_deactivate () at ~/src/php-src/Zend/zend.c:1186
#9  0x0000000000867d00 in php_request_shutdown (dummy=0x0) at ~/src/php-src/main/main.c:1923
#10 0x00000000009d8d57 in do_cli (argc=2, argv=0x163f0e0) at ~/src/php-src/sapi/cli/php_cli.c:1129
#11 0x00000000009d95de in main (argc=2, argv=0x163f0e0) at ~/src/php-src/sapi/cli/php_cli.c:1356