]> granicus.if.org Git - php/commitdiff
Fixed #73973 - debug_zval_dump() assertion error for resource consts with --enable...
authorandrewnester <andrew.nester.dev@gmail.com>
Tue, 24 Jan 2017 13:38:30 +0000 (16:38 +0300)
committerJoe Watkins <krakjoe@php.net>
Thu, 26 Jan 2017 09:03:47 +0000 (09:03 +0000)
NEWS
Zend/zend_builtin_functions.c
Zend/zend_execute_API.c
ext/standard/tests/general_functions/bug73973.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 686efb6643ad9f930d648a77f47ef5a26b3ca1d1..b0566a9ccc11a1ee7e132d810009245d8ed3143d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ PHP                                                                        NEWS
   . Fixed bug #73876 (Crash when exporting **= in expansion of assign op).
     (Sara)
   . Fixed bug #73969 (segfault in debug_print_backtrace). (andrewnester)
+  . Fixed bug #73973 (assertion error in debug_zval_dump). (andrewnester)
 
 - DOM:
   . Fixed bug #54382 (getAttributeNodeNS doesn't get xmlns* attributes).
index 547d3f0b8faec05e8462a9ac54c742c255daef57..aa705d323527635c47add78211328a5983625d6e 100644 (file)
@@ -808,9 +808,6 @@ static void copy_constant_array(zval *dst, zval *src) /* {{{ */
                        }
                } else if (Z_REFCOUNTED_P(val)) {
                        Z_ADDREF_P(val);
-                       if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_RESOURCE_EX)) {
-                               Z_TYPE_INFO_P(new_val) &= ~(IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT);
-                       }
                }
        } ZEND_HASH_FOREACH_END();
 }
@@ -853,12 +850,7 @@ repeat:
                case IS_FALSE:
                case IS_TRUE:
                case IS_NULL:
-                       break;
                case IS_RESOURCE:
-                       ZVAL_COPY(&val_free, val);
-                       /* TODO: better solution than this tricky disable dtor on resource? */
-                       Z_TYPE_INFO(val_free) &= ~(IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT);
-                       val = &val_free;
                        break;
                case IS_ARRAY:
                        if (!Z_IMMUTABLE_P(val)) {
index 51baac22505963b0f243d3a7e7add05f6bf57b29..28a75b7190f85e2e23b9a3cc0d0339cb84cb4ec1 100644 (file)
@@ -343,6 +343,10 @@ void shutdown_executor(void) /* {{{ */
                zend_llist_destroy(&CG(open_files));
        } zend_end_try();
 
+       zend_try {
+               clean_non_persistent_constants();
+    } zend_end_try();
+
        zend_try {
                zend_close_rsrc_list(&EG(regular_list));
        } zend_end_try();
@@ -374,10 +378,6 @@ void shutdown_executor(void) /* {{{ */
                }
        } zend_end_try();
 
-       zend_try {
-               clean_non_persistent_constants();
-       } zend_end_try();
-
        zend_try {
 #if 0&&ZEND_DEBUG
        signal(SIGSEGV, original_sigsegv_handler);
diff --git a/ext/standard/tests/general_functions/bug73973.phpt b/ext/standard/tests/general_functions/bug73973.phpt
new file mode 100644 (file)
index 0000000..8bb4daa
--- /dev/null
@@ -0,0 +1,9 @@
+--TEST--
+Bug #73973 debug_zval_dump() assertion error for resource consts with --enable-debug
+--FILE--
+<?php
+define('myerr', fopen('php://stderr', 'w'));
+debug_zval_dump(myerr);
+?>
+--EXPECTF--
+resource(5) of type (stream) refcount(%d)