From fd4025069d561b4196851c2e9a85b5bfdfe1465a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 5 May 2016 14:49:08 +0200 Subject: Enable HT RC assertions with escape-hatch HT functions that modify the array now assert that rc=1. As we don't respect this COW constraint everywhere, either for a good reason or because fixing it would take more work, we provide an escape hatch in the form of HT_ALLOW_COW_VIOLATION(ht). If this macro is called assertions on this ht are disabled. The macro is a no-op in release mode. --- main/php_variables.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'main/php_variables.c') diff --git a/main/php_variables.c b/main/php_variables.c index 9dd1860880..ff43466014 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -795,6 +795,11 @@ static zend_bool php_auto_globals_create_server(zend_string *name) zend_hash_update(&EG(symbol_table), name, &PG(http_globals)[TRACK_VARS_SERVER]); Z_ADDREF(PG(http_globals)[TRACK_VARS_SERVER]); + /* TODO: TRACK_VARS_SERVER is modified in a number of places (e.g. phar) past this point, + * where rc>1 due to the $_SERVER global. Ideally this shouldn't happen, but for now we + * ignore this issue, as it would probably require larger changes. */ + HT_ALLOW_COW_VIOLATION(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])); + return 0; /* don't rearm */ } -- cgit v1.2.1