You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1 #11716
PHP must be compiled with --enable-debug and CFLAGS="-DZEND_RC_DEBUG=1"
launch a cli server like php -S localhost:8888
terminate the process with a SIGINT (i.e. CTRL+C)
Here's the gdb backtrace:
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:440x00007fd65fdba15f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:780x00007fd65fd6c472 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:260x00007fd65fd564b2 in __GI_abort () at ./stdlib/abort.c:790x00007fd65fd563d5 in __assert_fail_base (fmt=0x7fd65fecadc8"%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=assertion@entry=0x5582e4bcde80"(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)",
file=file@entry=0x5582e4bcde18"/usr/src/php-src/Zend/zend_types.h", line=line@entry=1289,
function=function@entry=0x5582e4bce468 <__PRETTY_FUNCTION__.62> "zend_gc_delref") at ./assert/assert.c:920x00007fd65fd653a2 in __assert_fail (
assertion=0x5582e4bcde80"(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)",
file=0x5582e4bcde18"/usr/src/php-src/Zend/zend_types.h", line=1289,
function=0x5582e4bce468 <__PRETTY_FUNCTION__.62> "zend_gc_delref") at ./assert/assert.c:1010x00005582e4867e74 in zend_gc_delref (p=0x5582e52c8210) at /usr/src/php-src/Zend/zend_types.h:12890x00005582e4868109 in zend_string_release (s=0x5582e52c8210) at /usr/src/php-src/Zend/zend_string.h:3450x00005582e486e022 in zend_hash_destroy (ht=0x5582e50237a8 <server+648>) at /usr/src/php-src/Zend/zend_hash.c:17380x00005582e49d7e23 in php_cli_server_dtor (server=0x5582e5023520 <server>) at /usr/src/php-src/sapi/cli/php_cli_server.c:23330x00005582e49d8f82 in do_cli_server (argc=4, argv=0x5582e5150770) at /usr/src/php-src/sapi/cli/php_cli_server.c:28640x00005582e49cefeb in main (argc=4, argv=0x5582e5150770) at /usr/src/php-src/sapi/cli/php_cli.c:1340
CLI is single threaded, so clearly that hashtable is also local.
And also I think that persistent local hashtables should mark the strings they create as persistent local as well, that seems to make sense. Since GC_PERSISTENT_LOCAL is only used for debugging I guarded it with an #if.
But this is a bit of a shot in the dark, so I'd like confirmation from someone more accustomed to Zend.
@nielsdos this looks good. Do you want to make a PR? Otherwise, I will do. We may have the same issue with req->headers and req->headers_original_case in php_cli_server_request_ctor().
The cli server appears to be the only place where we destroy persistent hash tables before zend_rc_debug is set to false by php_module_shutdown(). This explains why we didn't need to take care of GC_PERSISTENT_LOCAL before in zend_hash.
Activity
ndossche commentedon Jul 16, 2023
I guess this works:
CLI is single threaded, so clearly that hashtable is also local.
And also I think that persistent local hashtables should mark the strings they create as persistent local as well, that seems to make sense. Since GC_PERSISTENT_LOCAL is only used for debugging I guarded it with an #if.
But this is a bit of a shot in the dark, so I'd like confirmation from someone more accustomed to Zend.
Girgias commentedon Jul 16, 2023
Assigning @arnaud-lb as they helped me figure out this sort of issue with strings last time I was doing something with the CLI
arnaud-lb commentedon Jul 21, 2023
@nielsdos this looks good. Do you want to make a PR? Otherwise, I will do. We may have the same issue with
req->headersandreq->headers_original_caseinphp_cli_server_request_ctor().The cli server appears to be the only place where we destroy persistent hash tables before
zend_rc_debugis set to false byphp_module_shutdown(). This explains why we didn't need to take care ofGC_PERSISTENT_LOCALbefore in zend_hash.ndossche commentedon Jul 21, 2023
@arnaud-lb Thank you for checking. I can create the PR soon and check the other cases.
Merge branch 'PHP-8.1' into PHP-8.2
Merge branch 'PHP-8.2'
Fix phpGH-11716: cli server crashes on SIGINT when compiled with ZEND…