Re: com php-src: Fixed bug #66461 (PHP crashes if opcache.interned_strings_buffer=0): NEWS ext/opcache/ZendAccelerator.c
ext/opcache/tests/bug66461.phpt

From: Date: Mon, 13 Jan 2014 19:12:25 +0000
Subject: Re: com php-src: Fixed bug #66461 (PHP crashes if opcache.interned_strings_buffer=0): NEWS ext/opcache/ZendAccelerator.c
ext/opcache/tests/bug66461.phpt
References: 1 2  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-75605@lists.php.net to get a copy of this message
You are completely right. It must be fixed now. Thanks. Dmitry. On Mon, Jan 13, 2014 at 9:22 PM, Nikita Popov <nikita.ppv@gmail.com> wrote: > On Mon, Jan 13, 2014 at 3:05 PM, Dmitry Stogov <dmitry@php.net> wrote: > >> Commit: ce2f024e9ff4283d22b30d0c20f83c976fb7d3ed >> Author: Dmitry Stogov <dmitry@zend.com> Mon, 13 Jan 2014 >> 18:05:21 +0400 >> Parents: fcd75690fe68c11ff9a327ee2e1ce3646b032431 >> Branches: PHP-5.5 PHP-5.6 master >> >> Link: >> >> http://git.php.net/?p=php-src.git;a=commitdiff;h=ce2f024e9ff4283d22b30d0c20f83c976fb7d3ed >> >> Log: >> Fixed bug #66461 (PHP crashes if opcache.interned_strings_buffer=0) >> >> Bugs: >> https://bugs.php.net/66461 >> >> Changed paths: >> M NEWS >> M ext/opcache/ZendAccelerator.c >> A ext/opcache/tests/bug66461.phpt >> >> >> Diff: >> diff --git a/NEWS b/NEWS >> index 07a9e7f..ae9bd72 100644 >> --- a/NEWS >> +++ b/NEWS >> @@ -9,6 +9,8 @@ PHP >> NEWS >> - OPCache: >> . Fixed bug #66474 (Optimizer bug in constant string to boolean >> conversion). >> (Dmitry) >> + . Fixed bug #66461 (PHP crashes if opcache.interned_strings_buffer=0). >> + (Dmitry) >> . Fixed bug #66298 (ext/opcache/Optimizer/zend_optimizer.c has >> dos-style >> ^M as lineend). (Laruence) >> >> diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c >> index 2e26170..d02a538 100644 >> --- a/ext/opcache/ZendAccelerator.c >> +++ b/ext/opcache/ZendAccelerator.c >> @@ -2128,7 +2128,9 @@ static void accel_activate(void) >> } >> >> #if (ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO) && !defined(ZTS) >> - >> accel_interned_strings_restore_state(TSRMLS_C); >> + if >> (ZCG(accel_directives).interned_strings_buffer) { >> + >> accel_interned_strings_restore_state(TSRMLS_C); >> + } >> #endif >> >> zend_shared_alloc_restore_state(); >> @@ -2446,36 +2448,39 @@ static int zend_accel_init_shm(TSRMLS_D) >> >> #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO >> >> + ZCSG(interned_strings_start) = ZCSG(interned_strings_end) = NULL; >> # ifndef ZTS >> zend_hash_init(&ZCSG(interned_strings), >> (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024) / >> (sizeof(Bucket) + sizeof(Bucket*) + 8 /* average string length */), NULL, >> NULL, 1); >> - ZCSG(interned_strings).nTableMask = >> ZCSG(interned_strings).nTableSize - 1; >> - ZCSG(interned_strings).arBuckets = >> zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(Bucket *)); >> - ZCSG(interned_strings_start) = >> zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * >> 1024)); >> - if (!ZCSG(interned_strings).arBuckets || >> !ZCSG(interned_strings_start)) { >> - zend_accel_error(ACCEL_LOG_FATAL, >> ACCELERATOR_PRODUCT_NAME " cannot allocate buffer for interned strings"); >> - return FAILURE; >> + if (ZCG(accel_directives).interned_strings_buffer) { >> + ZCSG(interned_strings).nTableMask = >> ZCSG(interned_strings).nTableSize - 1; >> + ZCSG(interned_strings).arBuckets = >> zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(Bucket *)); >> + ZCSG(interned_strings_start) = >> zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * >> 1024)); >> + if (!ZCSG(interned_strings).arBuckets || >> !ZCSG(interned_strings_start)) { >> + zend_accel_error(ACCEL_LOG_FATAL, >> ACCELERATOR_PRODUCT_NAME " cannot allocate buffer for interned strings"); >> + return FAILURE; >> + } >> + ZCSG(interned_strings_end) = >> ZCSG(interned_strings_start) + >> (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024); >> + ZCSG(interned_strings_top) = >> ZCSG(interned_strings_start); >> + >> + orig_interned_strings_start = CG(interned_strings_start); >> + orig_interned_strings_end = CG(interned_strings_end); >> + CG(interned_strings_start) = ZCSG(interned_strings_start); >> + CG(interned_strings_end) = ZCSG(interned_strings_end); >> } >> - ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + >> (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024); >> - ZCSG(interned_strings_top) = ZCSG(interned_strings_start); >> -# else >> - ZCSG(interned_strings_start) = ZCSG(interned_strings_end) = NULL; >> # endif >> >> - orig_interned_strings_start = CG(interned_strings_start); >> - orig_interned_strings_end = CG(interned_strings_end); >> orig_new_interned_string = zend_new_interned_string; >> orig_interned_strings_snapshot = zend_interned_strings_snapshot; >> orig_interned_strings_restore = zend_interned_strings_restore; >> - >> - CG(interned_strings_start) = ZCSG(interned_strings_start); >> - CG(interned_strings_end) = ZCSG(interned_strings_end); >> zend_new_interned_string = accel_new_interned_string_for_php; >> zend_interned_strings_snapshot = >> accel_interned_strings_snapshot_for_php; >> zend_interned_strings_restore = >> accel_interned_strings_restore_for_php; >> >> # ifndef ZTS >> - accel_use_shm_interned_strings(TSRMLS_C); >> - accel_interned_strings_save_state(TSRMLS_C); >> + if (ZCG(accel_directives).interned_strings_buffer) { >> + accel_use_shm_interned_strings(TSRMLS_C); >> + accel_interned_strings_save_state(TSRMLS_C); >> + } >> # endif >> >> #endif >> @@ -2709,13 +2714,15 @@ void accel_shutdown(TSRMLS_D) >> } >> >> #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO >> + if (ZCG(accel_directives).interned_strings_buffer) { >> # ifndef ZTS >> > > accel_free_ts_resources() is called a few lines above this, so if ZTS is > enabled ZCG is not available anymore (ZCG(accel_directives) will deref > NULL). So should either move this code further up or not do the check in > ZTS. > > Nikita >

« previous php.cvs (#75605) next »