Skip to content

Commit f15b50c

Browse files
Fix GH-16319: protect fiber backtrace with null filename from crashing
1 parent 68d5ddb commit f15b50c

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ PHP NEWS
1414
array). (ilutov)
1515
. Fixed bug GH-19480 (error_log php.ini cannot be unset when open_basedir is
1616
configured). (nielsdos)
17+
. Fixed bug GH-16319 (Prevent crash when displaying fiber backtrace with
18+
a null filename). (alexandre-daubois)
1719

1820
- Date:
1921
. Fixed GH-17159: "P" format for ::createFromFormat swallows string literals.

ext/zend_test/observer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static void observer_show_init(zend_function *fbc)
155155
php_printf("%*s<!-- init %s() -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->common.function_name));
156156
}
157157
} else {
158-
php_printf("%*s<!-- init '%s' -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->op_array.filename));
158+
php_printf("%*s<!-- init '%s' -->\n", 2 * ZT_G(observer_nesting_depth), "", fbc->op_array.filename ? ZSTR_VAL(fbc->op_array.filename) : "[no active file]");
159159
}
160160
}
161161

@@ -178,7 +178,7 @@ static void observer_show_init_backtrace(zend_execute_data *execute_data)
178178
php_printf("%*s%s()\n", indent, "", ZSTR_VAL(fbc->common.function_name));
179179
}
180180
} else {
181-
php_printf("%*s{main} %s\n", indent, "", ZSTR_VAL(fbc->op_array.filename));
181+
php_printf("%*s{main} %s\n", indent, "", fbc->op_array.filename ? ZSTR_VAL(fbc->op_array.filename) : "[no active file]");
182182
}
183183
} while ((ex = ex->prev_execute_data) != NULL);
184184
php_printf("%*s-->\n", 2 * ZT_G(observer_nesting_depth), "");
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
GH-16319 (Fiber backtrace with null filename should not crash)
3+
--EXTENSIONS--
4+
zend_test
5+
--INI--
6+
zend_test.observer.enabled=1
7+
zend_test.observer.show_init_backtrace=1
8+
--FILE--
9+
<?php
10+
$fiber = new Fiber(function() {});
11+
$fiber->start();
12+
echo "Test completed without crash\n";
13+
?>
14+
--EXPECTF--
15+
<!-- init '%s' -->
16+
<!--
17+
{main} %s
18+
-->
19+
<!-- init Fiber::__construct() -->
20+
<!--
21+
Fiber::__construct()
22+
{main} %s
23+
-->
24+
<!-- init Fiber::start() -->
25+
<!--
26+
Fiber::start()
27+
{main} %s
28+
-->
29+
<!-- init {closure}() -->
30+
<!--
31+
{closure}()
32+
{main} [no active file]
33+
Fiber::start()
34+
{main} %s
35+
-->
36+
Test completed without crash

0 commit comments

Comments
 (0)