-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1 #11716
Comments
I guess this works: diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index a8571af75c..4cdf681761 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -898,6 +898,11 @@ static zend_always_inline zval *_zend_hash_str_add_or_update_i(HashTable *ht, co
ht->nNumOfElements++;
p = ht->arData + idx;
p->key = key = zend_string_init(str, len, GC_FLAGS(ht) & IS_ARRAY_PERSISTENT);
+#if ZEND_RC_DEBUG
+ if (GC_FLAGS(ht) & GC_PERSISTENT_LOCAL) {
+ GC_MAKE_PERSISTENT_LOCAL(key);
+ }
+#endif
p->h = ZSTR_H(key) = h;
HT_FLAGS(ht) &= ~HASH_FLAG_STATIC_KEYS;
if (flag & HASH_LOOKUP) {
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 9c71b83580..5bcf736969 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -2320,6 +2320,7 @@ static void php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_
const php_cli_server_ext_mime_type_pair *pair;
zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1);
+ GC_MAKE_PERSISTENT_LOCAL(&server->extension_mime_types);
for (pair = mime_type_map; pair->ext; pair++) {
size_t ext_len = strlen(pair->ext);
CLI is single threaded, so clearly that hashtable is also local. |
Assigning @arnaud-lb as they helped me figure out this sort of issue with strings last time I was doing something with the CLI |
@nielsdos this looks good. Do you want to make a PR? Otherwise, I will do. We may have the same issue with The cli server appears to be the only place where we destroy persistent hash tables before |
@arnaud-lb Thank you for checking. I can create the PR soon and check the other cases. |
* PHP-8.1: Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1
* PHP-8.2: Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1
Description
Steps to reproduce:
--enable-debug
andCFLAGS="-DZEND_RC_DEBUG=1"
php -S localhost:8888
Here's the gdb backtrace:
Looks like this assertion:
fails when calling
PHP Version
php8.3-dev
Operating System
debian sid
The text was updated successfully, but these errors were encountered: