File tree Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ PHP NEWS
6565- SPL:
6666 . Fixed bug GH-16337 (Use-after-free in SplHeap). (nielsdos)
6767
68+ - Standard:
69+ . Fixed bug GH-16293 (Failed assertion when throwing in assert() callback with
70+ bail enabled). (ilutov)
71+
6872- XMLReader:
6973 . Fixed bug GH-16292 (Segmentation fault in ext/xmlreader/php_xmlreader.c).
7074 (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 @@ -238,6 +238,11 @@ PHP_FUNCTION(assert)
238238 }
239239
240240 if (ASSERTG (bail )) {
241+ if (EG (exception )) {
242+ /* The callback might have thrown. Use E_WARNING to print the
243+ * exception so we can avoid bailout and use unwind_exit. */
244+ zend_exception_error (EG (exception ), E_WARNING );
245+ }
241246 zend_throw_unwind_exit ();
242247 RETURN_THROWS ();
243248 } else {
You can’t perform that action at this time.
0 commit comments