com php-src: Merge branch 'PHP-5.6' into PHP-7.0: NEWS ext/opcache/README ext/opcache/ZendAccelerator.c ext/opcache/ZendAccelerator.h
ext/opcache/zend_accelerator_hash.c ext/opcache/zend_ accelerator_module.c
| From: | Dmitry Stogov | Date: | Wed, 16 Nov 2016 09:49:50 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.6' into PHP-7.0: NEWS ext/opcache/README ext/opcache/ZendAccelerator.c ext/opcache/ZendAccelerator.h ext/opcache/zend_accelerator_hash.c ext/opcache/zend_ accelerator_module.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95781@lists.php.net to get a copy of this message | ||
Commit: a1a5b52f3b9c819fec871601392b438a4ddecf14
Author: Dmitry Stogov <dmitry@zend.com> Wed, 16 Nov 2016 12:49:50 +0300
Parents: 22a43551a2fc25fc63bf53390c6ba0a1b8c742bf ecba563f2fa1e027ea91b9ee0d50611273852995
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a1a5b52f3b9c819fec871601392b438a4ddecf14
Log:
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
Fixed bug #69090 (check cached files permissions)
Bugs:
https://bugs.php.net/69090
Changed paths:
MM NEWS
MM ext/opcache/README
MM ext/opcache/ZendAccelerator.c
MM ext/opcache/ZendAccelerator.h
MM ext/opcache/zend_accelerator_hash.c
MM ext/opcache/zend_accelerator_module.c
diff --cc NEWS index a5b4271,9a2f915..6c78480 --- a/NEWS +++ b/NEWS @@@ -1,53 -1,26 +1,56 @@@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? 2016, PHP 5.6.29 +?? ??? 2016 PHP 7.0.14 + +- Calendar: + . Fix integer overflows (Joshua Rogers) + +- Core: + . Fixded bug #72736 (Slow performance when fetching large dataset with mysqli + / PDO). (Dmitry) + +- Date: + . Fixed bug #69587 (DateInterval properties and isset). (jhdxr) + +- ODBC: + . Fixed bug #73448 (odbc_errormsg returns trash, always 513 bytes). + (Anatol) + - Opcache: - . Fixed bug #73402 (Opcache segfault when using class constant to call a - method). (Laruence) + . Fixed bug #69090 (check cached files permissions) + -- OpenSSL - . Fixed bug #72776 (Invalid parameter in memcpy function trough - openssl_pbkdf2). (Jakub Zelenka) +- PCRE: + . Fixed bug #73392 (A use-after-free in zend allocator management). + (Laruence) + +- PDO_Firebird: + . Fixed bug #73087, #61183, #71494 (Memory corruption in bindParam). + (Dorin Marcoci) + +- SPL: + . Fixed bug #73423 (Reproducible crash with GDB backtrace). (Laruence) + +- XML: + . Fixed bug #72135 (malformed XML causes fault) (edgarsandi) -10 Nov 2016, PHP 5.6.28 +10 Nov 2016 PHP 7.0.13 - Core: + . Fixed bug #73350 (Exception::__toString() cause circular references). + (Laruence) + . Fixed bug #73181 (parse_str() without a second argument leads to crash). + (Nikita) + . Fixed bug #66773 (Autoload with Opcache allows importing conflicting class + name to namespace). (Nikita) + . Fixed bug #66862 ((Sub-)Namespaces unexpected behaviour). (Nikita) + . Fix pthreads detection when cross-compiling (ffontaine) . Fixed bug #73337 (try/catch not working with two exceptions inside a same operation). (Dmitry) + . Fixed bug #73338 (Exception thrown from error handler causes valgrind + warnings (and crashes)). (Bob, Dmitry) + . Fixed bug #73329 ((Float)"Nano" == NAN). (Anatol) -- Bz2: - . Fixed bug #73356 (crash in bzcompress function). (Stas) - --GD: +- GD: . Fixed bug #73213 (Integer overflow in imageline() with antialiasing). (cmb) . Fixed bug #73272 (imagescale() is not affected by, but affects imagesetinterpolation()). (cmb) diff --cc ext/opcache/ZendAccelerator.c index 38a9541,c8d2290..7bd6b81 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@@ -1747,22 -1592,28 +1747,36 @@@ zend_op_array *persistent_compile_file( persistent_script = NULL; } + /* Make sure we only increase the currently running processes semaphore + * once each execution (this function can be called more than once on + * each execution) + */ + if (!ZCG(counted)) { + if (accel_activate_add() == FAILURE) { +#ifdef HAVE_OPCACHE_FILE_CACHE + if (ZCG(accel_directives).file_cache) { + return file_cache_compile_file(file_handle, type); + } +#endif + return accelerator_orig_compile_file(file_handle, type); + } + ZCG(counted) = 1; + } + + /* Revalidate acessibility of cached file */ + if (EXPECTED(persistent_script != NULL) && + UNEXPECTED(ZCG(accel_directives).validate_permission) && + file_handle->type == ZEND_HANDLE_FILENAME && + UNEXPECTED(access(file_handle->filename, R_OK) != 0)) { + if (type == ZEND_REQUIRE) { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename); -#else + zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC); -#endif + zend_bailout(); + } else { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename); -#else + zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC); -#endif + } + return NULL; + } + SHM_UNPROTECT(); /* If script is found then validate_timestamps if option is enabled */ @@@ -2042,35 -2148,37 +2056,60 @@@ static void accel_activate(void return; } + if (!ZCG(function_table).nTableSize) { + zend_hash_init(&ZCG(function_table), zend_hash_num_elements(CG(function_table)), NULL, ZEND_FUNCTION_DTOR, 1); + zend_accel_copy_internal_functions(); + } + + /* PHP-5.4 and above return "double", but we use 1 sec precision */ + ZCG(auto_globals_mask) = 0; + ZCG(request_time) = (time_t)sapi_get_request_time(); + ZCG(cache_opline) = NULL; + ZCG(cache_persistent_script) = NULL; + ZCG(include_path_key_len) = 0; + ZCG(include_path_check) = 1; + + /* check if ZCG(function_table) wasn't somehow polluted on the way */ + if (ZCG(internal_functions_count) != zend_hash_num_elements(&ZCG(function_table))) { + zend_accel_error(ACCEL_LOG_WARNING, "Internal functions count changed - was %d, now %d", ZCG(internal_functions_count), zend_hash_num_elements(&ZCG(function_table))); + } + + ZCG(cwd) = NULL; + ZCG(cwd_key_len) = 0; + ZCG(cwd_check) = 1; + +#ifdef HAVE_OPCACHE_FILE_CACHE + if (ZCG(accel_directives).file_cache_only) { + return; + } +#endif + + #ifndef ZEND_WIN32 + if (ZCG(accel_directives).validate_root) { + struct stat buf; + + if (stat("/", &buf) != 0) { + ZCG(root_hash) = 0; + } else { - unsigned long x = buf.st_ino; ++ zend_ulong x = buf.st_ino; + -#if SIZEOF_LONG == 4 ++#if SIZEOF_ZEND_LONG == 4 + x = ((x >> 16) ^ x) * 0x45d9f3b; + x = ((x >> 16) ^ x) * 0x45d9f3b; + x = (x >> 16) ^ x; -#elif SIZEOF_LONG == 8 ++#elif SIZEOF_ZEND_LONG == 8 + x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; + x = (x ^ (x >> 27)) * 0x94d049bb133111eb; + x = x ^ (x >> 31); + #endif + ZCG(root_hash) = x; + } + } else { + ZCG(root_hash) = 0; + } + #endif + SHM_UNPROTECT(); - /* PHP-5.4 and above return "double", but we use 1 sec precision */ - ZCG(request_time) = (time_t)sapi_get_request_time(TSRMLS_C); - ZCG(cache_opline) = NULL; - ZCG(cache_persistent_script) = NULL; - ZCG(include_path_check) = !ZCG(include_path_key); if (ZCG(counted)) { #ifdef ZTS diff --cc ext/opcache/ZendAccelerator.h index 4daadc7,a711de7..976dae2 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@@ -202,8 -230,10 +202,10 @@@ typedef struct _zend_accel_directives zend_bool file_override_enabled; zend_bool inherited_hack; zend_bool enable_cli; - zend_ulong revalidate_freq; - zend_ulong file_update_protection; + zend_bool validate_permission; + zend_bool validate_root; - unsigned long revalidate_freq; - unsigned long file_update_protection; ++ zend_ulong revalidate_freq; ++ zend_ulong file_update_protection; char *error_log; #ifdef ZEND_WIN32 char *mmap_base; @@@ -241,25 -259,20 +243,28 @@@ typedef struct _zend_accel_globals zend_bool locked; /* thread obtained exclusive lock */ HashTable bind_hash; /* prototype and zval lookup table */ zend_accel_directives accel_directives; - char *cwd; /* current working directory or NULL */ - int cwd_len; /* "cwd" string length */ - char *include_path_key; /* one letter key of current "include_path" */ - char *include_path; /* current section of "include_path" directive */ - int include_path_len; /* "include_path" string length */ + zend_string *cwd; /* current working directory or NULL */ + zend_string *include_path; /* current value of "include_path" directive */ + char include_path_key[32]; /* key of current "include_path" */ + char cwd_key[32]; /* key of current working directory */ + int include_path_key_len; int include_path_check; + int cwd_key_len; + int cwd_check; + int auto_globals_mask; time_t request_time; + time_t last_restart_time; /* used to synchronize SHM and in-process caches */ + char system_id[32]; + HashTable xlat_table; + #ifndef ZEND_WIN32 - unsigned long root_hash; ++ zend_ulong root_hash; + #endif /* preallocated shared-memory block to save current script */ void *mem; + void *arena_mem; + zend_persistent_script *current_persistent_script; /* cache to save hash lookup on the same INCLUDE opcode */ - zend_op *cache_opline; + const zend_op *cache_opline; zend_persistent_script *cache_persistent_script; /* preallocated buffer for keys */ int key_len; diff --cc ext/opcache/zend_accelerator_hash.c index a533d06,4b8b712..7ec64ce --- a/ext/opcache/zend_accelerator_hash.c +++ b/ext/opcache/zend_accelerator_hash.c @@@ -137,11 -140,22 +140,17 @@@ zend_accel_hash_entry* zend_accel_hash_ return entry; } -/* Returns the data associated with key on success - * Returns NULL if data doesn't exist - */ -void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, zend_uint key_length) +static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, char *key, uint32_t key_length, zend_ulong hash_value, int data) { - zend_ulong index = hash_value % accel_hash->max_num_entries; - zend_accel_hash_entry *entry = accel_hash->hash_table[index]; - zend_ulong hash_value; + zend_ulong index; + zend_accel_hash_entry *entry; - hash_value = zend_inline_hash_func(key, key_length); + #ifndef ZEND_WIN32 + hash_value ^= ZCG(root_hash); + #endif + index = hash_value % accel_hash->max_num_entries; + + entry = accel_hash->hash_table[index]; while (entry) { if (entry->hash_value == hash_value && entry->key_length == key_length diff --cc ext/opcache/zend_accelerator_module.c index 81dc6d6,0faa915..e331d04 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@@ -241,37 -251,12 +241,39 @@@ static ZEND_INI_MH(OnEnable } } +#ifdef HAVE_OPCACHE_FILE_CACHE +static ZEND_INI_MH(OnUpdateFileCache) +{ + if (new_value) { + if (!ZSTR_LEN(new_value)) { + new_value = NULL; + } else { + zend_stat_t buf; + + if (!IS_ABSOLUTE_PATH(ZSTR_VAL(new_value), ZSTR_LEN(new_value)) || + zend_stat(ZSTR_VAL(new_value), &buf) != 0 || + !S_ISDIR(buf.st_mode) || +#ifndef ZEND_WIN32 + access(ZSTR_VAL(new_value), R_OK | W_OK | X_OK) != 0) { +#else + _access(ZSTR_VAL(new_value), 06) != 0) { +#endif + zend_accel_error(ACCEL_LOG_WARNING, "opcache.file_cache must be a full path of accessable directory.\n"); + new_value = NULL; + } + } + } + OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); + return SUCCESS; +} +#endif + ZEND_INI_BEGIN() - STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_ALL, OnEnable, enabled , zend_accel_globals, accel_globals) + STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_ALL, OnEnable, enabled , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.use_cwd" , "1", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.use_cwd , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.validate_timestamps", "1", PHP_INI_ALL , OnUpdateBool, accel_directives.validate_timestamps, zend_accel_globals, accel_globals) + STD_PHP_INI_BOOLEAN("opcache.validate_permission", "0", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.validate_permission, zend_accel_globals, accel_globals) + STD_PHP_INI_BOOLEAN("opcache.validate_root" , "0", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.validate_root , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.inherited_hack" , "1", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.inherited_hack , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.dups_fix" , "0", PHP_INI_ALL , OnUpdateBool, accel_directives.ignore_dups , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.revalidate_path" , "0", PHP_INI_ALL , OnUpdateBool, accel_directives.revalidate_path , zend_accel_globals, accel_globals) @@@ -685,56 -659,54 +687,58 @@@ static ZEND_FUNCTION(opcache_get_config array_init(return_value); /* directives */ - MAKE_STD_ZVAL(directives); - array_init(directives); - add_assoc_bool(directives, "opcache.enable", ZCG(enabled)); - add_assoc_bool(directives, "opcache.enable_cli", ZCG(accel_directives).enable_cli); - add_assoc_bool(directives, "opcache.use_cwd", ZCG(accel_directives).use_cwd); - add_assoc_bool(directives, "opcache.validate_timestamps", ZCG(accel_directives).validate_timestamps); - add_assoc_bool(directives, "opcache.validate_permission", ZCG(accel_directives).validate_permission); - add_assoc_bool(directives, "opcache.validate_root", ZCG(accel_directives).validate_root); - add_assoc_bool(directives, "opcache.inherited_hack", ZCG(accel_directives).inherited_hack); - add_assoc_bool(directives, "opcache.dups_fix", ZCG(accel_directives).ignore_dups); - add_assoc_bool(directives, "opcache.revalidate_path", ZCG(accel_directives).revalidate_path); - - add_assoc_long(directives, "opcache.log_verbosity_level", ZCG(accel_directives).log_verbosity_level); - add_assoc_long(directives, "opcache.memory_consumption", ZCG(accel_directives).memory_consumption); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - add_assoc_long(directives, "opcache.interned_strings_buffer",ZCG(accel_directives).interned_strings_buffer); + array_init(&directives); + add_assoc_bool(&directives, "opcache.enable", ZCG(enabled)); + add_assoc_bool(&directives, "opcache.enable_cli", ZCG(accel_directives).enable_cli); + add_assoc_bool(&directives, "opcache.use_cwd", ZCG(accel_directives).use_cwd); + add_assoc_bool(&directives, "opcache.validate_timestamps", ZCG(accel_directives).validate_timestamps); ++ add_assoc_bool(&directives, "opcache.validate_permission", ZCG(accel_directives).validate_permission); ++ add_assoc_bool(&directives, "opcache.validate_root", ZCG(accel_directives).validate_root); + add_assoc_bool(&directives, "opcache.inherited_hack", ZCG(accel_directives).inherited_hack); + add_assoc_bool(&directives, "opcache.dups_fix", ZCG(accel_directives).ignore_dups); + add_assoc_bool(&directives, "opcache.revalidate_path", ZCG(accel_directives).revalidate_path); + + add_assoc_long(&directives, "opcache.log_verbosity_level", ZCG(accel_directives).log_verbosity_level); + add_assoc_long(&directives, "opcache.memory_consumption", ZCG(accel_directives).memory_consumption); + add_assoc_long(&directives, "opcache.interned_strings_buffer",ZCG(accel_directives).interned_strings_buffer); + add_assoc_long(&directives, "opcache.max_accelerated_files", ZCG(accel_directives).max_accelerated_files); + add_assoc_double(&directives, "opcache.max_wasted_percentage", ZCG(accel_directives).max_wasted_percentage); + add_assoc_long(&directives, "opcache.consistency_checks", ZCG(accel_directives).consistency_checks); + add_assoc_long(&directives, "opcache.force_restart_timeout", ZCG(accel_directives).force_restart_timeout); + add_assoc_long(&directives, "opcache.revalidate_freq", ZCG(accel_directives).revalidate_freq); + add_assoc_string(&directives, "opcache.preferred_memory_model", STRING_NOT_NULL(ZCG(accel_directives).memory_model)); + add_assoc_string(&directives, "opcache.blacklist_filename", STRING_NOT_NULL(ZCG(accel_directives).user_blacklist_filename)); + add_assoc_long(&directives, "opcache.max_file_size", ZCG(accel_directives).max_file_size); + add_assoc_string(&directives, "opcache.error_log", STRING_NOT_NULL(ZCG(accel_directives).error_log)); + + add_assoc_bool(&directives, "opcache.protect_memory", ZCG(accel_directives).protect_memory); + add_assoc_bool(&directives, "opcache.save_comments", ZCG(accel_directives).save_comments); + add_assoc_bool(&directives, "opcache.fast_shutdown", ZCG(accel_directives).fast_shutdown); + add_assoc_bool(&directives, "opcache.enable_file_override", ZCG(accel_directives).file_override_enabled); + add_assoc_long(&directives, "opcache.optimization_level", ZCG(accel_directives).optimization_level); + +#ifndef ZEND_WIN32 + add_assoc_string(&directives, "opcache.lockfile_path", STRING_NOT_NULL(ZCG(accel_directives).lockfile_path)); #endif - add_assoc_long(directives, "opcache.max_accelerated_files", ZCG(accel_directives).max_accelerated_files); - add_assoc_double(directives, "opcache.max_wasted_percentage", ZCG(accel_directives).max_wasted_percentage); - add_assoc_long(directives, "opcache.consistency_checks", ZCG(accel_directives).consistency_checks); - add_assoc_long(directives, "opcache.force_restart_timeout", ZCG(accel_directives).force_restart_timeout); - add_assoc_long(directives, "opcache.revalidate_freq", ZCG(accel_directives).revalidate_freq); - add_assoc_string(directives, "opcache.preferred_memory_model", STRING_NOT_NULL(ZCG(accel_directives).memory_model), 1); - add_assoc_string(directives, "opcache.blacklist_filename", STRING_NOT_NULL(ZCG(accel_directives).user_blacklist_filename), 1); - add_assoc_long(directives, "opcache.max_file_size", ZCG(accel_directives).max_file_size); - add_assoc_string(directives, "opcache.error_log", STRING_NOT_NULL(ZCG(accel_directives).error_log), 1); - - add_assoc_bool(directives, "opcache.protect_memory", ZCG(accel_directives).protect_memory); - add_assoc_bool(directives, "opcache.save_comments", ZCG(accel_directives).save_comments); - add_assoc_bool(directives, "opcache.load_comments", ZCG(accel_directives).load_comments); - add_assoc_bool(directives, "opcache.fast_shutdown", ZCG(accel_directives).fast_shutdown); - add_assoc_bool(directives, "opcache.enable_file_override", ZCG(accel_directives).file_override_enabled); - add_assoc_long(directives, "opcache.optimization_level", ZCG(accel_directives).optimization_level); - - add_assoc_zval(return_value, "directives", directives); + +#ifdef HAVE_OPCACHE_FILE_CACHE + add_assoc_string(&directives, "opcache.file_cache", ZCG(accel_directives).file_cache ? ZCG(accel_directives).file_cache : ""); + add_assoc_bool(&directives, "opcache.file_cache_only", ZCG(accel_directives).file_cache_only); + add_assoc_bool(&directives, "opcache.file_cache_consistency_checks", ZCG(accel_directives).file_cache_consistency_checks); +#endif + + add_assoc_zval(return_value, "directives", &directives); /*version */ - MAKE_STD_ZVAL(version); - array_init(version); - add_assoc_string(version, "version", ACCELERATOR_VERSION, 1); - add_assoc_string(version, "opcache_product_name", ACCELERATOR_PRODUCT_NAME, 1); - add_assoc_zval(return_value, "version", version); + array_init(&version); + add_assoc_string(&version, "version", PHP_VERSION); + add_assoc_string(&version, "opcache_product_name", ACCELERATOR_PRODUCT_NAME); + add_assoc_zval(return_value, "version", &version); /* blacklist */ - MAKE_STD_ZVAL(blacklist); - array_init(blacklist); - zend_accel_blacklist_apply(&accel_blacklist, (apply_func_arg_t) add_blacklist_path, blacklist TSRMLS_CC); - add_assoc_zval(return_value, "blacklist", blacklist); + array_init(&blacklist); + zend_accel_blacklist_apply(&accel_blacklist, add_blacklist_path, &blacklist); + add_assoc_zval(return_value, "blacklist", &blacklist); } /* {{{ proto void accelerator_reset()
diff --cc NEWS index a5b4271,9a2f915..6c78480 --- a/NEWS +++ b/NEWS @@@ -1,53 -1,26 +1,56 @@@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? 2016, PHP 5.6.29 +?? ??? 2016 PHP 7.0.14 + +- Calendar: + . Fix integer overflows (Joshua Rogers) + +- Core: + . Fixded bug #72736 (Slow performance when fetching large dataset with mysqli + / PDO). (Dmitry) + +- Date: + . Fixed bug #69587 (DateInterval properties and isset). (jhdxr) + +- ODBC: + . Fixed bug #73448 (odbc_errormsg returns trash, always 513 bytes). + (Anatol) + - Opcache: - . Fixed bug #73402 (Opcache segfault when using class constant to call a - method). (Laruence) + . Fixed bug #69090 (check cached files permissions) + -- OpenSSL - . Fixed bug #72776 (Invalid parameter in memcpy function trough - openssl_pbkdf2). (Jakub Zelenka) +- PCRE: + . Fixed bug #73392 (A use-after-free in zend allocator management). + (Laruence) + +- PDO_Firebird: + . Fixed bug #73087, #61183, #71494 (Memory corruption in bindParam). + (Dorin Marcoci) + +- SPL: + . Fixed bug #73423 (Reproducible crash with GDB backtrace). (Laruence) + +- XML: + . Fixed bug #72135 (malformed XML causes fault) (edgarsandi) -10 Nov 2016, PHP 5.6.28 +10 Nov 2016 PHP 7.0.13 - Core: + . Fixed bug #73350 (Exception::__toString() cause circular references). + (Laruence) + . Fixed bug #73181 (parse_str() without a second argument leads to crash). + (Nikita) + . Fixed bug #66773 (Autoload with Opcache allows importing conflicting class + name to namespace). (Nikita) + . Fixed bug #66862 ((Sub-)Namespaces unexpected behaviour). (Nikita) + . Fix pthreads detection when cross-compiling (ffontaine) . Fixed bug #73337 (try/catch not working with two exceptions inside a same operation). (Dmitry) + . Fixed bug #73338 (Exception thrown from error handler causes valgrind + warnings (and crashes)). (Bob, Dmitry) + . Fixed bug #73329 ((Float)"Nano" == NAN). (Anatol) -- Bz2: - . Fixed bug #73356 (crash in bzcompress function). (Stas) - --GD: +- GD: . Fixed bug #73213 (Integer overflow in imageline() with antialiasing). (cmb) . Fixed bug #73272 (imagescale() is not affected by, but affects imagesetinterpolation()). (cmb) diff --cc ext/opcache/ZendAccelerator.c index 38a9541,c8d2290..7bd6b81 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@@ -1747,22 -1592,28 +1747,36 @@@ zend_op_array *persistent_compile_file( persistent_script = NULL; } + /* Make sure we only increase the currently running processes semaphore + * once each execution (this function can be called more than once on + * each execution) + */ + if (!ZCG(counted)) { + if (accel_activate_add() == FAILURE) { +#ifdef HAVE_OPCACHE_FILE_CACHE + if (ZCG(accel_directives).file_cache) { + return file_cache_compile_file(file_handle, type); + } +#endif + return accelerator_orig_compile_file(file_handle, type); + } + ZCG(counted) = 1; + } + + /* Revalidate acessibility of cached file */ + if (EXPECTED(persistent_script != NULL) && + UNEXPECTED(ZCG(accel_directives).validate_permission) && + file_handle->type == ZEND_HANDLE_FILENAME && + UNEXPECTED(access(file_handle->filename, R_OK) != 0)) { + if (type == ZEND_REQUIRE) { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename); -#else + zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC); -#endif + zend_bailout(); + } else { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename); -#else + zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC); -#endif + } + return NULL; + } + SHM_UNPROTECT(); /* If script is found then validate_timestamps if option is enabled */ @@@ -2042,35 -2148,37 +2056,60 @@@ static void accel_activate(void return; } + if (!ZCG(function_table).nTableSize) { + zend_hash_init(&ZCG(function_table), zend_hash_num_elements(CG(function_table)), NULL, ZEND_FUNCTION_DTOR, 1); + zend_accel_copy_internal_functions(); + } + + /* PHP-5.4 and above return "double", but we use 1 sec precision */ + ZCG(auto_globals_mask) = 0; + ZCG(request_time) = (time_t)sapi_get_request_time(); + ZCG(cache_opline) = NULL; + ZCG(cache_persistent_script) = NULL; + ZCG(include_path_key_len) = 0; + ZCG(include_path_check) = 1; + + /* check if ZCG(function_table) wasn't somehow polluted on the way */ + if (ZCG(internal_functions_count) != zend_hash_num_elements(&ZCG(function_table))) { + zend_accel_error(ACCEL_LOG_WARNING, "Internal functions count changed - was %d, now %d", ZCG(internal_functions_count), zend_hash_num_elements(&ZCG(function_table))); + } + + ZCG(cwd) = NULL; + ZCG(cwd_key_len) = 0; + ZCG(cwd_check) = 1; + +#ifdef HAVE_OPCACHE_FILE_CACHE + if (ZCG(accel_directives).file_cache_only) { + return; + } +#endif + + #ifndef ZEND_WIN32 + if (ZCG(accel_directives).validate_root) { + struct stat buf; + + if (stat("/", &buf) != 0) { + ZCG(root_hash) = 0; + } else { - unsigned long x = buf.st_ino; ++ zend_ulong x = buf.st_ino; + -#if SIZEOF_LONG == 4 ++#if SIZEOF_ZEND_LONG == 4 + x = ((x >> 16) ^ x) * 0x45d9f3b; + x = ((x >> 16) ^ x) * 0x45d9f3b; + x = (x >> 16) ^ x; -#elif SIZEOF_LONG == 8 ++#elif SIZEOF_ZEND_LONG == 8 + x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; + x = (x ^ (x >> 27)) * 0x94d049bb133111eb; + x = x ^ (x >> 31); + #endif + ZCG(root_hash) = x; + } + } else { + ZCG(root_hash) = 0; + } + #endif + SHM_UNPROTECT(); - /* PHP-5.4 and above return "double", but we use 1 sec precision */ - ZCG(request_time) = (time_t)sapi_get_request_time(TSRMLS_C); - ZCG(cache_opline) = NULL; - ZCG(cache_persistent_script) = NULL; - ZCG(include_path_check) = !ZCG(include_path_key); if (ZCG(counted)) { #ifdef ZTS diff --cc ext/opcache/ZendAccelerator.h index 4daadc7,a711de7..976dae2 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@@ -202,8 -230,10 +202,10 @@@ typedef struct _zend_accel_directives zend_bool file_override_enabled; zend_bool inherited_hack; zend_bool enable_cli; - zend_ulong revalidate_freq; - zend_ulong file_update_protection; + zend_bool validate_permission; + zend_bool validate_root; - unsigned long revalidate_freq; - unsigned long file_update_protection; ++ zend_ulong revalidate_freq; ++ zend_ulong file_update_protection; char *error_log; #ifdef ZEND_WIN32 char *mmap_base; @@@ -241,25 -259,20 +243,28 @@@ typedef struct _zend_accel_globals zend_bool locked; /* thread obtained exclusive lock */ HashTable bind_hash; /* prototype and zval lookup table */ zend_accel_directives accel_directives; - char *cwd; /* current working directory or NULL */ - int cwd_len; /* "cwd" string length */ - char *include_path_key; /* one letter key of current "include_path" */ - char *include_path; /* current section of "include_path" directive */ - int include_path_len; /* "include_path" string length */ + zend_string *cwd; /* current working directory or NULL */ + zend_string *include_path; /* current value of "include_path" directive */ + char include_path_key[32]; /* key of current "include_path" */ + char cwd_key[32]; /* key of current working directory */ + int include_path_key_len; int include_path_check; + int cwd_key_len; + int cwd_check; + int auto_globals_mask; time_t request_time; + time_t last_restart_time; /* used to synchronize SHM and in-process caches */ + char system_id[32]; + HashTable xlat_table; + #ifndef ZEND_WIN32 - unsigned long root_hash; ++ zend_ulong root_hash; + #endif /* preallocated shared-memory block to save current script */ void *mem; + void *arena_mem; + zend_persistent_script *current_persistent_script; /* cache to save hash lookup on the same INCLUDE opcode */ - zend_op *cache_opline; + const zend_op *cache_opline; zend_persistent_script *cache_persistent_script; /* preallocated buffer for keys */ int key_len; diff --cc ext/opcache/zend_accelerator_hash.c index a533d06,4b8b712..7ec64ce --- a/ext/opcache/zend_accelerator_hash.c +++ b/ext/opcache/zend_accelerator_hash.c @@@ -137,11 -140,22 +140,17 @@@ zend_accel_hash_entry* zend_accel_hash_ return entry; } -/* Returns the data associated with key on success - * Returns NULL if data doesn't exist - */ -void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, zend_uint key_length) +static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, char *key, uint32_t key_length, zend_ulong hash_value, int data) { - zend_ulong index = hash_value % accel_hash->max_num_entries; - zend_accel_hash_entry *entry = accel_hash->hash_table[index]; - zend_ulong hash_value; + zend_ulong index; + zend_accel_hash_entry *entry; - hash_value = zend_inline_hash_func(key, key_length); + #ifndef ZEND_WIN32 + hash_value ^= ZCG(root_hash); + #endif + index = hash_value % accel_hash->max_num_entries; + + entry = accel_hash->hash_table[index]; while (entry) { if (entry->hash_value == hash_value && entry->key_length == key_length diff --cc ext/opcache/zend_accelerator_module.c index 81dc6d6,0faa915..e331d04 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@@ -241,37 -251,12 +241,39 @@@ static ZEND_INI_MH(OnEnable } } +#ifdef HAVE_OPCACHE_FILE_CACHE +static ZEND_INI_MH(OnUpdateFileCache) +{ + if (new_value) { + if (!ZSTR_LEN(new_value)) { + new_value = NULL; + } else { + zend_stat_t buf; + + if (!IS_ABSOLUTE_PATH(ZSTR_VAL(new_value), ZSTR_LEN(new_value)) || + zend_stat(ZSTR_VAL(new_value), &buf) != 0 || + !S_ISDIR(buf.st_mode) || +#ifndef ZEND_WIN32 + access(ZSTR_VAL(new_value), R_OK | W_OK | X_OK) != 0) { +#else + _access(ZSTR_VAL(new_value), 06) != 0) { +#endif + zend_accel_error(ACCEL_LOG_WARNING, "opcache.file_cache must be a full path of accessable directory.\n"); + new_value = NULL; + } + } + } + OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); + return SUCCESS; +} +#endif + ZEND_INI_BEGIN() - STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_ALL, OnEnable, enabled , zend_accel_globals, accel_globals) + STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_ALL, OnEnable, enabled , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.use_cwd" , "1", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.use_cwd , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.validate_timestamps", "1", PHP_INI_ALL , OnUpdateBool, accel_directives.validate_timestamps, zend_accel_globals, accel_globals) + STD_PHP_INI_BOOLEAN("opcache.validate_permission", "0", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.validate_permission, zend_accel_globals, accel_globals) + STD_PHP_INI_BOOLEAN("opcache.validate_root" , "0", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.validate_root , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.inherited_hack" , "1", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.inherited_hack , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.dups_fix" , "0", PHP_INI_ALL , OnUpdateBool, accel_directives.ignore_dups , zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.revalidate_path" , "0", PHP_INI_ALL , OnUpdateBool, accel_directives.revalidate_path , zend_accel_globals, accel_globals) @@@ -685,56 -659,54 +687,58 @@@ static ZEND_FUNCTION(opcache_get_config array_init(return_value); /* directives */ - MAKE_STD_ZVAL(directives); - array_init(directives); - add_assoc_bool(directives, "opcache.enable", ZCG(enabled)); - add_assoc_bool(directives, "opcache.enable_cli", ZCG(accel_directives).enable_cli); - add_assoc_bool(directives, "opcache.use_cwd", ZCG(accel_directives).use_cwd); - add_assoc_bool(directives, "opcache.validate_timestamps", ZCG(accel_directives).validate_timestamps); - add_assoc_bool(directives, "opcache.validate_permission", ZCG(accel_directives).validate_permission); - add_assoc_bool(directives, "opcache.validate_root", ZCG(accel_directives).validate_root); - add_assoc_bool(directives, "opcache.inherited_hack", ZCG(accel_directives).inherited_hack); - add_assoc_bool(directives, "opcache.dups_fix", ZCG(accel_directives).ignore_dups); - add_assoc_bool(directives, "opcache.revalidate_path", ZCG(accel_directives).revalidate_path); - - add_assoc_long(directives, "opcache.log_verbosity_level", ZCG(accel_directives).log_verbosity_level); - add_assoc_long(directives, "opcache.memory_consumption", ZCG(accel_directives).memory_consumption); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - add_assoc_long(directives, "opcache.interned_strings_buffer",ZCG(accel_directives).interned_strings_buffer); + array_init(&directives); + add_assoc_bool(&directives, "opcache.enable", ZCG(enabled)); + add_assoc_bool(&directives, "opcache.enable_cli", ZCG(accel_directives).enable_cli); + add_assoc_bool(&directives, "opcache.use_cwd", ZCG(accel_directives).use_cwd); + add_assoc_bool(&directives, "opcache.validate_timestamps", ZCG(accel_directives).validate_timestamps); ++ add_assoc_bool(&directives, "opcache.validate_permission", ZCG(accel_directives).validate_permission); ++ add_assoc_bool(&directives, "opcache.validate_root", ZCG(accel_directives).validate_root); + add_assoc_bool(&directives, "opcache.inherited_hack", ZCG(accel_directives).inherited_hack); + add_assoc_bool(&directives, "opcache.dups_fix", ZCG(accel_directives).ignore_dups); + add_assoc_bool(&directives, "opcache.revalidate_path", ZCG(accel_directives).revalidate_path); + + add_assoc_long(&directives, "opcache.log_verbosity_level", ZCG(accel_directives).log_verbosity_level); + add_assoc_long(&directives, "opcache.memory_consumption", ZCG(accel_directives).memory_consumption); + add_assoc_long(&directives, "opcache.interned_strings_buffer",ZCG(accel_directives).interned_strings_buffer); + add_assoc_long(&directives, "opcache.max_accelerated_files", ZCG(accel_directives).max_accelerated_files); + add_assoc_double(&directives, "opcache.max_wasted_percentage", ZCG(accel_directives).max_wasted_percentage); + add_assoc_long(&directives, "opcache.consistency_checks", ZCG(accel_directives).consistency_checks); + add_assoc_long(&directives, "opcache.force_restart_timeout", ZCG(accel_directives).force_restart_timeout); + add_assoc_long(&directives, "opcache.revalidate_freq", ZCG(accel_directives).revalidate_freq); + add_assoc_string(&directives, "opcache.preferred_memory_model", STRING_NOT_NULL(ZCG(accel_directives).memory_model)); + add_assoc_string(&directives, "opcache.blacklist_filename", STRING_NOT_NULL(ZCG(accel_directives).user_blacklist_filename)); + add_assoc_long(&directives, "opcache.max_file_size", ZCG(accel_directives).max_file_size); + add_assoc_string(&directives, "opcache.error_log", STRING_NOT_NULL(ZCG(accel_directives).error_log)); + + add_assoc_bool(&directives, "opcache.protect_memory", ZCG(accel_directives).protect_memory); + add_assoc_bool(&directives, "opcache.save_comments", ZCG(accel_directives).save_comments); + add_assoc_bool(&directives, "opcache.fast_shutdown", ZCG(accel_directives).fast_shutdown); + add_assoc_bool(&directives, "opcache.enable_file_override", ZCG(accel_directives).file_override_enabled); + add_assoc_long(&directives, "opcache.optimization_level", ZCG(accel_directives).optimization_level); + +#ifndef ZEND_WIN32 + add_assoc_string(&directives, "opcache.lockfile_path", STRING_NOT_NULL(ZCG(accel_directives).lockfile_path)); #endif - add_assoc_long(directives, "opcache.max_accelerated_files", ZCG(accel_directives).max_accelerated_files); - add_assoc_double(directives, "opcache.max_wasted_percentage", ZCG(accel_directives).max_wasted_percentage); - add_assoc_long(directives, "opcache.consistency_checks", ZCG(accel_directives).consistency_checks); - add_assoc_long(directives, "opcache.force_restart_timeout", ZCG(accel_directives).force_restart_timeout); - add_assoc_long(directives, "opcache.revalidate_freq", ZCG(accel_directives).revalidate_freq); - add_assoc_string(directives, "opcache.preferred_memory_model", STRING_NOT_NULL(ZCG(accel_directives).memory_model), 1); - add_assoc_string(directives, "opcache.blacklist_filename", STRING_NOT_NULL(ZCG(accel_directives).user_blacklist_filename), 1); - add_assoc_long(directives, "opcache.max_file_size", ZCG(accel_directives).max_file_size); - add_assoc_string(directives, "opcache.error_log", STRING_NOT_NULL(ZCG(accel_directives).error_log), 1); - - add_assoc_bool(directives, "opcache.protect_memory", ZCG(accel_directives).protect_memory); - add_assoc_bool(directives, "opcache.save_comments", ZCG(accel_directives).save_comments); - add_assoc_bool(directives, "opcache.load_comments", ZCG(accel_directives).load_comments); - add_assoc_bool(directives, "opcache.fast_shutdown", ZCG(accel_directives).fast_shutdown); - add_assoc_bool(directives, "opcache.enable_file_override", ZCG(accel_directives).file_override_enabled); - add_assoc_long(directives, "opcache.optimization_level", ZCG(accel_directives).optimization_level); - - add_assoc_zval(return_value, "directives", directives); + +#ifdef HAVE_OPCACHE_FILE_CACHE + add_assoc_string(&directives, "opcache.file_cache", ZCG(accel_directives).file_cache ? ZCG(accel_directives).file_cache : ""); + add_assoc_bool(&directives, "opcache.file_cache_only", ZCG(accel_directives).file_cache_only); + add_assoc_bool(&directives, "opcache.file_cache_consistency_checks", ZCG(accel_directives).file_cache_consistency_checks); +#endif + + add_assoc_zval(return_value, "directives", &directives); /*version */ - MAKE_STD_ZVAL(version); - array_init(version); - add_assoc_string(version, "version", ACCELERATOR_VERSION, 1); - add_assoc_string(version, "opcache_product_name", ACCELERATOR_PRODUCT_NAME, 1); - add_assoc_zval(return_value, "version", version); + array_init(&version); + add_assoc_string(&version, "version", PHP_VERSION); + add_assoc_string(&version, "opcache_product_name", ACCELERATOR_PRODUCT_NAME); + add_assoc_zval(return_value, "version", &version); /* blacklist */ - MAKE_STD_ZVAL(blacklist); - array_init(blacklist); - zend_accel_blacklist_apply(&accel_blacklist, (apply_func_arg_t) add_blacklist_path, blacklist TSRMLS_CC); - add_assoc_zval(return_value, "blacklist", blacklist); + array_init(&blacklist); + zend_accel_blacklist_apply(&accel_blacklist, add_blacklist_path, &blacklist); + add_assoc_zval(return_value, "blacklist", &blacklist); } /* {{{ proto void accelerator_reset()