Skip to content

Commit 87ebd12

Browse files
committed
Merge branch 'master' into jit-dynasm
* master: (23 commits) Update README information for the libmbfl library Refactor mbstring READMEs Remove code examples from dom extension Remove old apache_hooks occurrence Remove some old apache2filter occurrences Remove unused Travis configuration for sapi/phpdbg Remove README from ext/tidy in favor of the PHP docs Remove outdated README from ext/com_dotnet Remove done TODO file from date extension Bugfix #74556 stream_socket_get_name() returns null bytes on MacOS Add line numbers to Optimizer debug output Fixed bug #75318 (The parameter of UConverter::getAliases() is not optional) Add line numbers to Opcache's zend_dump_op() debug output mb_convert_variables() refactored to use simple recursion. Fixed incorrect recursion protection (previous implementation kept protection flag or apply counter in non-zero state). Fixed incorrect recursion detection HASH_FLAG_PERSISTENT renamed into IS_ARRAY_PERSISTENT and moved into GC_FLAGS (to be consistent with IS_STR_PERSISTENT). Refactored recursion pretection Join untracked files to root .gitignore Remove ident gitattribute for Zend/RFC/ Remove PHP examples from simplexml ...
2 parents c7e6a3c + 3ed3bc3 commit 87ebd12

File tree

103 files changed

+652
-2683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+652
-2683
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ ext/dba/libcdb/cdb.c ident
1717
ext/filter/filter.c ident
1818
README.input_filter ident
1919
run-tests.php ident
20-
Zend/RFCs/002.txt ident
21-
Zend/RFCs/003.txt ident
2220
ext/exif/exif.c ident
2321
ext/ldap/ldap.c ident
2422
ext/pdo_pgsql/pdo_pgsql.c ident

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ ext/mbstring/libmbfl/filters/Makefile.in
141141
ext/mbstring/libmbfl/mbfl/Makefile.in
142142
ext/mbstring/libmbfl/mbfl/EastAsianWidth.txt
143143
ext/mbstring/libmbfl/nls/Makefile.in
144+
ext/mbstring/oniguruma/oniguruma.h
144145
ext/mssql/#*#
145146
ext/mssql/Makefile.global
146147
ext/mssql/acinclude.m4
@@ -188,9 +189,15 @@ sapi/fpm/php-fpm.1
188189
sapi/fpm/init.d.php-fpm
189190
sapi/fpm/php-fpm.conf
190191
sapi/fpm/fpm/php-cgi
192+
sapi/fpm/php-fpm.8
193+
sapi/fpm/php-fpm.service
194+
sapi/fpm/status.html
195+
sapi/fpm/www.conf
191196
sapi/phpdbg/phpdbg_parser.c
192197
sapi/phpdbg/phpdbg_parser.h
193198
sapi/phpdbg/phpdbg
199+
sapi/phpdbg/build
200+
sapi/phpdbg/*.output
194201
scripts/php-config
195202
scripts/phpize
196203
scripts/man1/*.1
@@ -231,4 +238,3 @@ win32/wsyslog.h
231238
# special cases to invert previous ignore rules
232239
!ext/fileinfo/libmagic.patch
233240
!ext/mbstring/oniguruma.patch
234-

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ BCMath:
5555
5. Changed Functions
5656
========================================
5757

58+
. debug_zval_dump() was changed to display recursive arrays and objects
59+
in the same way as var_dump(). Now, it doesn't display them twice.
60+
5861
========================================
5962
6. New Functions
6063
========================================

UPGRADING.INTERNALS

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ PHP 7.2 INTERNALS UPGRADE NOTES
1111
h. valid_symbol_table removed
1212
i. array_init() and array_init_size()
1313
j. Run-time constant operand addressing
14+
k. Array/Object recursion protection
15+
l. HASH_FLAG_PERSISTENT
1416

1517
2. Build system changes
1618
a. Unix build system changes
@@ -70,6 +72,21 @@ PHP 7.2 INTERNALS UPGRADE NOTES
7072
RT_CONSTANT_EX, EX_CONSTANT should be substituted by RT_CONSTANT than now
7173
use "opline" (instead of "op_array") as first argument.
7274

75+
k. Protection from recursion during processing circular data structures was
76+
refactored. HashTable.nApplyCount and IS_OBJ_APPLY_COUNT are replaced by
77+
single flag GC_PROTECTED. Corresponding macros Z_OBJ_APPLY_COUNT,
78+
Z_OBJ_INC_APPLY_COUNT, Z_OBJ_DEC_APPLY_COUNT, ZEND_HASH_GET_APPLY_COUNT,
79+
ZEND_HASH_INC_APPLY_COUNT, ZEND_HASH_DEC_APPLY_COUNT are replaced with
80+
GC_IS_RECURSIVE, GC_PROTECT_RECURSION, GC_UNPROTECT_RECURSION,
81+
Z_IS_RECURSIVE, Z_PROTECT_RECURSION, Z_UNPROTECT_RECURSION.
82+
83+
HASH_FLAG_APPLY_PROTECTION flag and ZEND_HASH_APPLY_PROTECTION() macro
84+
are removed. All mutable arrays should use recursion protection.
85+
Corresponding checks should be replaced by Z_REFCOUNTED() or
86+
!(GC_GLAGS(p) & GC_IMMUTABLE).
87+
88+
l. HASH_FLAG_PERSISTENT renamed into IS_ARRAY_PERSISTENT and moved into
89+
GC_FLAGS (to be consistent with IS_STR_PERSISTENT).
7390

7491
========================
7592
2. Build system changes

Zend/tests/gc_032.phpt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ array(1) refcount(%d){
1818
[0]=>
1919
array(1) refcount(%d){
2020
[0]=>
21-
array(1) refcount(%d){
22-
[0]=>
23-
*RECURSION*
24-
}
21+
*RECURSION*
2522
}
2623
}
2724
array(1) refcount(%d){
@@ -30,13 +27,7 @@ array(1) refcount(%d){
3027
[0]=>
3128
array(1) refcount(%d){
3229
[0]=>
33-
array(1) refcount(%d){
34-
[0]=>
35-
array(1) refcount(%d){
36-
[0]=>
37-
*RECURSION*
38-
}
39-
}
30+
*RECURSION*
4031
}
4132
}
4233
}

Zend/zend.c

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,17 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
334334
switch (Z_TYPE_P(expr)) {
335335
case IS_ARRAY:
336336
ZEND_PUTS("Array (");
337-
if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) &&
338-
++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) {
339-
ZEND_PUTS(" *RECURSION*");
340-
Z_ARRVAL_P(expr)->u.v.nApplyCount--;
341-
return;
337+
if (Z_REFCOUNTED_P(expr)) {
338+
if (Z_IS_RECURSIVE_P(expr)) {
339+
ZEND_PUTS(" *RECURSION*");
340+
return;
341+
}
342+
Z_PROTECT_RECURSION_P(expr);
342343
}
343344
print_flat_hash(Z_ARRVAL_P(expr));
344345
ZEND_PUTS(")");
345-
if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
346-
Z_ARRVAL_P(expr)->u.v.nApplyCount--;
346+
if (Z_REFCOUNTED_P(expr)) {
347+
Z_UNPROTECT_RECURSION_P(expr);
347348
}
348349
break;
349350
case IS_OBJECT:
@@ -353,7 +354,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
353354
zend_printf("%s Object (", ZSTR_VAL(class_name));
354355
zend_string_release(class_name);
355356

356-
if (Z_OBJ_APPLY_COUNT_P(expr) > 0) {
357+
if (Z_IS_RECURSIVE_P(expr)) {
357358
ZEND_PUTS(" *RECURSION*");
358359
return;
359360
}
@@ -362,9 +363,9 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
362363
properties = Z_OBJPROP_P(expr);
363364
}
364365
if (properties) {
365-
Z_OBJ_INC_APPLY_COUNT_P(expr);
366+
Z_PROTECT_RECURSION_P(expr);
366367
print_flat_hash(properties);
367-
Z_OBJ_DEC_APPLY_COUNT_P(expr);
368+
Z_UNPROTECT_RECURSION_P(expr);
368369
}
369370
ZEND_PUTS(")");
370371
break;
@@ -384,15 +385,16 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
384385
switch (Z_TYPE_P(expr)) {
385386
case IS_ARRAY:
386387
smart_str_appends(buf, "Array\n");
387-
if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) &&
388-
++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) {
389-
smart_str_appends(buf, " *RECURSION*");
390-
Z_ARRVAL_P(expr)->u.v.nApplyCount--;
391-
return;
388+
if (Z_REFCOUNTED_P(expr)) {
389+
if (Z_IS_RECURSIVE_P(expr)) {
390+
smart_str_appends(buf, " *RECURSION*");
391+
return;
392+
}
393+
Z_PROTECT_RECURSION_P(expr);
392394
}
393395
print_hash(buf, Z_ARRVAL_P(expr), indent, 0);
394-
if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
395-
Z_ARRVAL_P(expr)->u.v.nApplyCount--;
396+
if (Z_REFCOUNTED_P(expr)) {
397+
Z_UNPROTECT_RECURSION_P(expr);
396398
}
397399
break;
398400
case IS_OBJECT:
@@ -405,17 +407,17 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
405407
zend_string_release(class_name);
406408

407409
smart_str_appends(buf, " Object\n");
408-
if (Z_OBJ_APPLY_COUNT_P(expr) > 0) {
410+
if (Z_IS_RECURSIVE_P(expr)) {
409411
smart_str_appends(buf, " *RECURSION*");
410412
return;
411413
}
412414
if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) {
413415
break;
414416
}
415417

416-
Z_OBJ_INC_APPLY_COUNT_P(expr);
418+
Z_PROTECT_RECURSION_P(expr);
417419
print_hash(buf, properties, indent, 1);
418-
Z_OBJ_DEC_APPLY_COUNT_P(expr);
420+
Z_UNPROTECT_RECURSION_P(expr);
419421

420422
if (is_temp) {
421423
zend_hash_destroy(properties);

Zend/zend_builtin_functions.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,13 +727,13 @@ static int validate_constant_array(HashTable *ht) /* {{{ */
727727
int ret = 1;
728728
zval *val;
729729

730-
ht->u.v.nApplyCount++;
730+
GC_PROTECT_RECURSION(ht);
731731
ZEND_HASH_FOREACH_VAL_IND(ht, val) {
732732
ZVAL_DEREF(val);
733733
if (Z_REFCOUNTED_P(val)) {
734734
if (Z_TYPE_P(val) == IS_ARRAY) {
735735
if (Z_REFCOUNTED_P(val)) {
736-
if (Z_ARRVAL_P(val)->u.v.nApplyCount > 0) {
736+
if (Z_IS_RECURSIVE_P(val)) {
737737
zend_error(E_WARNING, "Constants cannot be recursive arrays");
738738
ret = 0;
739739
break;
@@ -749,7 +749,7 @@ static int validate_constant_array(HashTable *ht) /* {{{ */
749749
}
750750
}
751751
} ZEND_HASH_FOREACH_END();
752-
ht->u.v.nApplyCount--;
752+
GC_UNPROTECT_RECURSION(ht);
753753
return ret;
754754
}
755755
/* }}} */
@@ -1137,7 +1137,7 @@ ZEND_FUNCTION(get_object_vars)
11371137

11381138
zobj = Z_OBJ_P(obj);
11391139

1140-
if (!zobj->ce->default_properties_count && properties == zobj->properties && !ZEND_HASH_GET_APPLY_COUNT(properties)) {
1140+
if (!zobj->ce->default_properties_count && properties == zobj->properties && !GC_IS_RECURSIVE(properties)) {
11411141
/* fast copy */
11421142
if (EXPECTED(zobj->handlers == &std_object_handlers)) {
11431143
RETURN_ARR(zend_proptable_to_symtable(properties, 0));

Zend/zend_exceptions.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,9 @@ ZEND_METHOD(exception, __toString)
711711
zend_string_release(file);
712712
zval_ptr_dtor(&trace);
713713

714-
Z_OBJPROP_P(exception)->u.v.nApplyCount++;
714+
Z_PROTECT_RECURSION_P(exception);
715715
exception = GET_PROPERTY(exception, ZEND_STR_PREVIOUS);
716-
if (exception && Z_TYPE_P(exception) == IS_OBJECT && Z_OBJPROP_P(exception)->u.v.nApplyCount > 0) {
716+
if (exception && Z_TYPE_P(exception) == IS_OBJECT && Z_IS_RECURSIVE_P(exception)) {
717717
break;
718718
}
719719
}
@@ -722,8 +722,8 @@ ZEND_METHOD(exception, __toString)
722722
exception = getThis();
723723
/* Reset apply counts */
724724
while (exception && Z_TYPE_P(exception) == IS_OBJECT && (base_ce = i_get_exception_base(exception)) && instanceof_function(Z_OBJCE_P(exception), base_ce)) {
725-
if (Z_OBJPROP_P(exception)->u.v.nApplyCount) {
726-
Z_OBJPROP_P(exception)->u.v.nApplyCount--;
725+
if (Z_IS_RECURSIVE_P(exception)) {
726+
Z_UNPROTECT_RECURSION_P(exception);
727727
} else {
728728
break;
729729
}

0 commit comments

Comments
 (0)