Skip to content

Commit af77d3b

Browse files
committed
Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1
Closes GH-11757.
1 parent 429f20e commit af77d3b

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.1.23
44

5+
- CLI:
6+
. Fixed bug GH-11716 (cli server crashes on SIGINT when compiled with
7+
ZEND_RC_DEBUG=1). (nielsdos)
8+
59
- FFI:
610
. Fix leaking definitions when using FFI::cdef()->new(...). (ilutov)
711

Zend/zend_hash.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,11 @@ static zend_always_inline zval *_zend_hash_str_add_or_update_i(HashTable *ht, co
878878
ht->nNumOfElements++;
879879
p = ht->arData + idx;
880880
p->key = key = zend_string_init(str, len, GC_FLAGS(ht) & IS_ARRAY_PERSISTENT);
881+
#if ZEND_RC_DEBUG
882+
if (GC_FLAGS(ht) & GC_PERSISTENT_LOCAL) {
883+
GC_MAKE_PERSISTENT_LOCAL(key);
884+
}
885+
#endif
881886
p->h = ZSTR_H(key) = h;
882887
HT_FLAGS(ht) &= ~HASH_FLAG_STATIC_KEYS;
883888
if (flag & HASH_LOOKUP) {

sapi/cli/php_cli_server.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,9 @@ static int php_cli_server_request_ctor(php_cli_server_request *req) /* {{{ */
13401340
req->query_string = NULL;
13411341
req->query_string_len = 0;
13421342
zend_hash_init(&req->headers, 0, NULL, char_ptr_dtor_p, 1);
1343+
GC_MAKE_PERSISTENT_LOCAL(&req->headers);
13431344
zend_hash_init(&req->headers_original_case, 0, NULL, NULL, 1);
1345+
GC_MAKE_PERSISTENT_LOCAL(&req->headers_original_case);
13441346
req->content = NULL;
13451347
req->content_len = 0;
13461348
req->ext = NULL;
@@ -2248,6 +2250,7 @@ static int php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_s
22482250
const php_cli_server_ext_mime_type_pair *pair;
22492251

22502252
zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1);
2253+
GC_MAKE_PERSISTENT_LOCAL(&server->extension_mime_types);
22512254

22522255
for (pair = mime_type_map; pair->ext; pair++) {
22532256
size_t ext_len = strlen(pair->ext);

0 commit comments

Comments
 (0)