|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-12-15 15:46 UTC] maroszek at gmx dot net
Description: ------------ PHP 7 is current stable PHP 7 is build as a static library ./configure '--disable-fpm' '--disable-cgi' '--disable-cli' '--enable-embed=static' '--enable-maintainer-zts' '--without-iconv' g++ --version > Apple LLVM version 7.0.2 (clang-700.1.81) > Target: x86_64-apple-darwin15.2.0 > Thread model: posix I build a simple example to demonstrate the threading problem. On OS X the example crashes within a second. Sourcecode: https://gist.github.com/paresy/b4babb919a86e9764bc4 Copy crash.cpp into your php7 folder. Compile with: g++ crash.cpp -Imain -Itsrm -Izend -I. --std=c++11 -Llibs -lphp7 -lxml2 -lresolv empty.php: <? Start it. It should crash. :-) PS: PHP 5.5 and probably 5.6 is affected as well. Expected result: ---------------- No crash. Endless loop doing the work. Actual result: -------------- Segmentation fault: 11 and a lot of warnings which make no real sense: <b>Fatal error</b>: Maximum execution time of 30 seconds exceeded in <b>Unknown</b> on line <b>0</b><br /> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 23:00:02 2025 UTC |
I reproduced the problem under Debian 8 aswell. uname -a Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u5 (2015-10-09) x86_64 GNU/Linux g++ --version > g++ (Debian 4.9.2-10) 4.9.2 Here is the output from gdb: Program received signal SIGSEGV, Segmentation fault. zend_mm_free_heap (ptr=0xecaff0, heap=0x7fffec000040) at /home/user/Downloads/php-7.0.0/Zend/zend_alloc.c:1400 1400 ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted"); Backtrace: #0 zend_mm_free_heap (ptr=0xecaff0, heap=0x7fffec000040) at /home/user/Downloads/php-7.0.0/Zend/zend_alloc.c:1400 #1 _efree (ptr=0xecaff0) at /home/user/Downloads/php-7.0.0/Zend/zend_alloc.c:2458 #2 0x0000000000489d65 in zend_string_release (s=<optimized out>) at /home/user/Downloads/php-7.0.0/Zend/zend_string.h:271 #3 _zend_hash_del_el_ex (prev=<optimized out>, p=<optimized out>, idx=<optimized out>, ht=<optimized out>) at /home/user/Downloads/php-7.0.0/Zend/zend_hash.c:986 #4 _zend_hash_del_el (p=0x7fffec056100, idx=0, ht=0x7fffd4024370) at /home/user/Downloads/php-7.0.0/Zend/zend_hash.c:1016 #5 zend_hash_graceful_reverse_destroy (ht=0x7fffd4024370) at /home/user/Downloads/php-7.0.0/Zend/zend_hash.c:1468 #6 0x0000000000468995 in shutdown_executor () at /home/user/Downloads/php-7.0.0/Zend/zend_execute_API.c:277 #7 0x0000000000478798 in zend_deactivate () at /home/user/Downloads/php-7.0.0/Zend/zend.c:967 #8 0x0000000000419239 in php_request_shutdown (dummy=<optimized out>) at /home/user/Downloads/php-7.0.0/main/main.c:1810 #9 0x0000000000415893 in main::{lambda()#1}::operator()() const ()Thanks for the update. Yeah, now it works. Please check whether this fixes the issue on your side diff --git a/Zend/zend.c b/Zend/zend.c index ec520b8..e122b04 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -467,7 +467,7 @@ static void auto_global_copy_ctor(zval *zv) /* {{{ */ zend_auto_global *old_ag = (zend_auto_global *) Z_PTR_P(zv); zend_auto_global *new_ag = pemalloc(sizeof(zend_auto_global), 1); - new_ag->name = old_ag->name; + new_ag->name = zend_string_dup(old_ag->name, 0); new_ag->auto_global_callback = old_ag->auto_global_callback; new_ag->jit = old_ag->jit; It namely didn't crash on my side, but after some debugging valgrind showed issues. This seems pretty matching with the recent bug #71115. Thanks.Confirmed that using the code int argc2 = 1; char* text = "embed4"; char *argv2[2] = { text, NULL }; php_embed_init(argc2, argv2); to replace sapi_startup and php_embed_module.startup and deleting the "php_embed_module" struct (duplicate symbol error) allows the code to work. I have created a sample file which can test both versions (http://pastebin.com/8sHjP9Jy). When run with #define TEST1 0 the test fails, but when run with #define TEST1 1 it passses. In my case, the script was "echo 1" and proceeded to give an infinite loop of 1s to the std out. The question also needs addressing whether or not we can set the embed module elements and use embed init. I think so, but it is another difference between the code peices.Adding the lines php_embed_module.ub_write = php_embed_ub_write; php_embed_module.flush = php_embed_flush; after php_embed_init works so long as nothing is done with the output. Uncommenting "std::cout << str;" inside of php_embed_ub_write causes a segmentation fault "pointer being freed was not allocated" reliably inside the shutdown executor.