File tree 4 files changed +47
-0
lines changed 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ PHP NEWS
57
57
- SPL:
58
58
. Fixed bug GH-16337 (Use-after-free in SplHeap). (nielsdos)
59
59
60
+ - Standard:
61
+ . Fixed bug GH-16293 (Failed assertion when throwing in assert() callback with
62
+ bail enabled). (ilutov)
63
+
60
64
- XMLReader:
61
65
. Fixed bug GH-16292 (Segmentation fault in ext/xmlreader/php_xmlreader.c).
62
66
(nielsdos)
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16293: Exception in assert() callback with bail enabled
3
+ --FILE--
4
+ <?php
5
+
6
+ assert_options (ASSERT_EXCEPTION , 0 );
7
+ assert_options (ASSERT_BAIL , 1 );
8
+ assert_options (ASSERT_CALLBACK , 'f1 ' );
9
+ assert (false );
10
+
11
+ ?>
12
+ --EXPECTF--
13
+ Warning: assert(): assert(false) failed in %s on line %d
14
+
15
+ Warning: Uncaught Error: Invalid callback f1, function "f1" not found or invalid function name in %s:%d
16
+ Stack trace:
17
+ #0 %s(%d): assert(false, 'assert(false)')
18
+ #1 {main}
19
+ thrown in %s on line %d
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16293: Exception in assert() callback with bail enabled
3
+ --FILE--
4
+ <?php
5
+
6
+ assert_options (ASSERT_EXCEPTION , 0 );
7
+ assert_options (ASSERT_BAIL , 1 );
8
+ assert_options (ASSERT_CALLBACK , function () {
9
+ throw new Exception ('Boo ' );
10
+ });
11
+ assert (false );
12
+
13
+ ?>
14
+ --EXPECTF--
15
+ Warning: assert(): assert(false) failed in %s on line %d
16
+
17
+ Warning: Uncaught Exception: Boo in %s:%d
18
+ Stack trace:
19
+ %a
Original file line number Diff line number Diff line change @@ -195,6 +195,11 @@ PHP_FUNCTION(assert)
195
195
}
196
196
197
197
if (ASSERTG (bail )) {
198
+ if (EG (exception )) {
199
+ /* The callback might have thrown. Use E_WARNING to print the
200
+ * exception so we can avoid bailout and use unwind_exit. */
201
+ zend_exception_error (EG (exception ), E_WARNING );
202
+ }
198
203
zend_throw_unwind_exit ();
199
204
RETURN_THROWS ();
200
205
} else {
You can’t perform that action at this time.
0 commit comments