From c3260b66c9723d63c75f4f63aa2b9f52c6915d6f Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 11 Nov 2015 12:06:38 +0800 Subject: [PATCH 1/2] Revert "Fixed bug #70249 (Segmentation fault while running PHPUnit tests on phpBB 3.2-dev)" This reverts commit d6c527830e57c85356916e2efc2e6f120d493051. --- NEWS | 4 --- ext/standard/basic_functions.c | 13 ++------- .../tests/general_functions/bug70249.phpt | 28 ------------------- 3 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 ext/standard/tests/general_functions/bug70249.phpt diff --git a/NEWS b/NEWS index 3ebc7de1e77..6a88338f6e8 100644 --- a/NEWS +++ b/NEWS @@ -2,10 +2,6 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2015, PHP 7.0.1 -- Standard: - . Fixed bug #70249 (Segmentation fault while running PHPUnit tests on - phpBB 3.2-dev). (Laruence) - - Streams/Socket . Add IPV6_V6ONLY constant / make it usable in stream contexts. (Bob) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 1c5f3fe988b..8da45c42876 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5002,16 +5002,9 @@ PHPAPI void php_call_shutdown_functions(void) /* {{{ */ { if (BG(user_shutdown_function_names)) { zend_try { - zval *entry; - for (zend_hash_internal_pointer_reset(BG(user_shutdown_function_names)); - zend_hash_has_more_elements(BG(user_shutdown_function_names)) == SUCCESS; - zend_hash_move_forward(BG(user_shutdown_function_names))) { - if ((entry = zend_hash_get_current_data(BG(user_shutdown_function_names))) == NULL) { - continue; - } - user_shutdown_function_call(entry); - } - } zend_end_try(); + zend_hash_apply(BG(user_shutdown_function_names), user_shutdown_function_call); + } + zend_end_try(); php_free_shutdown_functions(); } } diff --git a/ext/standard/tests/general_functions/bug70249.phpt b/ext/standard/tests/general_functions/bug70249.phpt deleted file mode 100644 index aed8dccee3c..00000000000 --- a/ext/standard/tests/general_functions/bug70249.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Bug #70249 (Segmentation fault while running PHPUnit tests on phpBB 3.2-dev) ---FILE-- -flush(); - // make sure log entries written by shutdown functions are also flushed - // ensure "flush()" is called last when there are multiple shutdown functions - register_shutdown_function([$this, 'flush'], true); - }); - } - - public function flush($final = false) { - return 1; - } -} - -for ($i = 0; $i < 200; $i++) { - $a = new Logger(); -} -?> -okey ---EXPECT-- -okey From 82f503f5874a6d1d632ccf7c4b4ad3df20f9ba39 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 11 Nov 2015 12:31:45 +0800 Subject: [PATCH 2/2] Re-Fixed bug #70249 (Segmentation fault while running PHPUnit tests on phpBB 3.2-dev) Let's fixed this in the root instead --- NEWS | 4 +++ Zend/zend_hash.c | 15 +++++----- .../tests/general_functions/bug70249.phpt | 28 +++++++++++++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 ext/standard/tests/general_functions/bug70249.phpt diff --git a/NEWS b/NEWS index 6a88338f6e8..53f4d405fbb 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2015, PHP 7.0.1 +- Core: + . Fixed bug #70249 (Segmentation fault while running PHPUnit tests on + phpBB 3.2-dev). (Laruence) + - Streams/Socket . Add IPV6_V6ONLY constant / make it usable in stream contexts. (Bob) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 52868cf4a6d..c324f1dfa8b 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -1458,8 +1458,8 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_fu HT_ASSERT(GC_REFCOUNT(ht) == 1); HASH_PROTECT_RECURSION(ht); - p = ht->arData; - for (idx = 0; idx < ht->nNumUsed; idx++, p++) { + for (idx = 0; idx < ht->nNumUsed; idx++) { + p = ht->arData + idx; if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue; result = apply_func(&p->val); @@ -1484,8 +1484,8 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_f HT_ASSERT(GC_REFCOUNT(ht) == 1); HASH_PROTECT_RECURSION(ht); - p = ht->arData; - for (idx = 0; idx < ht->nNumUsed; idx++, p++) { + for (idx = 0; idx < ht->nNumUsed; idx++) { + p = ht->arData + idx; if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue; result = apply_func(&p->val, argument); @@ -1513,8 +1513,8 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply_with_arguments(HashTable *ht, apply_ HASH_PROTECT_RECURSION(ht); - p = ht->arData; - for (idx = 0; idx < ht->nNumUsed; idx++, p++) { + for (idx = 0; idx < ht->nNumUsed; idx++) { + p = ht->arData + idx; if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue; va_start(args, num_args); hash_key.h = p->h; @@ -1547,10 +1547,9 @@ ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t HASH_PROTECT_RECURSION(ht); idx = ht->nNumUsed; - p = ht->arData + idx; while (idx > 0) { idx--; - p--; + p = ht->arData + idx; if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue; result = apply_func(&p->val); diff --git a/ext/standard/tests/general_functions/bug70249.phpt b/ext/standard/tests/general_functions/bug70249.phpt new file mode 100644 index 00000000000..743df83ba06 --- /dev/null +++ b/ext/standard/tests/general_functions/bug70249.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #70249 (Segmentation fault while running PHPUnit tests on phpBB 3.2-dev) +--FILE-- +flush(); + // make sure log entries written by shutdown functions are also flushed + // ensure "flush()" is called last when there are multiple shutdown functions + register_shutdown_function([$this, 'flush'], true); + }); + } + + public function flush($final = false) { + return 1; + } +} + +for ($i = 0; $i < 200; $i++) { + $a = new Logger(); +} +?> +okey +--EXPECT-- +okey