From 533b1df7325673bf8159263379579d2142f57877 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 3 Jul 2014 13:38:38 +0800 Subject: [PATCH 1/2] Add test for bug #67215 bjori> writing a testcase making sure you get a fatal error and does not segfault after that... is difficult --- ext/opcache/tests/bug67215.phpt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ext/opcache/tests/bug67215.phpt diff --git a/ext/opcache/tests/bug67215.phpt b/ext/opcache/tests/bug67215.phpt new file mode 100644 index 00000000000..e9919d10011 --- /dev/null +++ b/ext/opcache/tests/bug67215.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #67215 (php-cgi work with opcache, may be segmentation fault happen) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +--SKIPIF-- + +--FILE-- +"); +file_put_contents($file_p, ''); +require $file_c; +$a = new c(); +require $file_c; +?> +--CLEAN-- + +--EXPECTF-- +Fatal error: Cannot redeclare class c in %sbug67215.c.php on line %d From 2034ace0526657cbed0fafc3d77b1baa6604ae9e Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 3 Jul 2014 14:58:37 +0800 Subject: [PATCH 2/2] Fixed bug #67215 (php-cgi work with opcache, may be segmentation fault happen) --- NEWS | 6 +++++- ext/opcache/zend_accelerator_util_funcs.c | 13 ++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index ca7ca7b4ffc..89bb30a82b6 100644 --- a/NEWS +++ b/NEWS @@ -18,7 +18,11 @@ PHP NEWS (Adam) - FPM: - . Fix bug #67531 (syslog cannot be set in pool configuration). (Remi) + . Fixed bug #67531 (syslog cannot be set in pool configuration). (Remi) + +- OPCache: + . Fixed bug #67215 (php-cgi work with opcache, may be segmentation fault + happen) (Dmitry, Laruence) - pgsql: . Fix bug #67550 (Error in code "form" instead of "from", pgsql.c, line 756), diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index 14c6f7490f6..dbab902b26f 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -837,16 +837,11 @@ static int zend_hash_unique_copy(HashTable *target, HashTable *source, unique_co if (p->nKeyLength > 0 && p->arKey[0] == 0) { /* Mangled key */ #if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO - if (((zend_function*)p->pData)->common.fn_flags & ZEND_ACC_CLOSURE) { - /* update closure */ - if (zend_hash_quick_update(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &t) == SUCCESS) { - if (pCopyConstructor) { - pCopyConstructor(t); - } + if (zend_hash_quick_update(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &t) == SUCCESS) { + if (pCopyConstructor) { + pCopyConstructor(t); } - } else { - /* ignore and wait for runtime */ - } + } #endif } else if (!ignore_dups && zend_hash_quick_find(target, p->arKey, p->nKeyLength, p->h, &t) == SUCCESS) { *fail_data = p->pData;