com php-src: Re-Fixed bug #70249 (Segmentation fault while running PHPUnit tests on phpBB 3.2-dev): Zend/zend_hash.c ext/standard/te
sts/general_functions/bug70249.phpt
| From: | Anatol Belski | Date: | Wed, 11 Nov 2015 09:58:36 +0000 |
| Subject: | com php-src: Re-Fixed bug #70249 (Segmentation fault while running PHPUnit tests on phpBB 3.2-dev): Zend/zend_hash.c ext/standard/te sts/general_functions/bug70249.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89747@lists.php.net to get a copy of this message | ||
Commit: 524d777188e3d00ec261e77ee9fb40eca9fdf437
Author: Xinchen Hui <laruence@gmail.com> Wed, 11 Nov 2015 12:31:45 +0800
Committer: Anatol Belski <ab@php.net> Wed, 11 Nov 2015 10:58:36 +0100
Parents: 7beb0d449f417b568e70f5550e49027ee67ea5db
Branches: PHP-7.0.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=524d777188e3d00ec261e77ee9fb40eca9fdf437
Log:
Re-Fixed bug #70249 (Segmentation fault while running PHPUnit tests on phpBB 3.2-dev)
Let's fixed this in the root instead
Bugs:
https://bugs.php.net/70249
Changed paths:
M Zend/zend_hash.c
A ext/standard/tests/general_functions/bug70249.phpt
Diff:
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index 52868cf..c324f1d 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 0000000..743df83
--- /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--
+<?php
+
+class Logger {
+ public function __construct() {
+ register_shutdown_function(function () {
+ // make regular flush before other shutdown functions, which allows session data
collection and so on
+ $this->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