1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Fix GH-16319: protect fiber backtrace with null filename from crashing (#19973)

This commit is contained in:
Alexandre Daubois
2025-10-01 11:24:58 +02:00
committed by GitHub
parent b7fdfb7147
commit 9fc14a90c6
2 changed files with 50 additions and 2 deletions

View File

@@ -155,7 +155,7 @@ static void observer_show_init(zend_function *fbc)
php_printf("%*s<!-- init %s() -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->common.function_name));
}
} else {
php_printf("%*s<!-- init '%s' -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->op_array.filename));
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]");
}
}
@@ -178,7 +178,7 @@ static void observer_show_init_backtrace(zend_execute_data *execute_data)
php_printf("%*s%s()\n", indent, "", ZSTR_VAL(fbc->common.function_name));
}
} else {
php_printf("%*s{main} %s\n", indent, "", ZSTR_VAL(fbc->op_array.filename));
php_printf("%*s{main} %s\n", indent, "", fbc->op_array.filename ? ZSTR_VAL(fbc->op_array.filename) : "[no active file]");
}
} while ((ex = ex->prev_execute_data) != NULL);
php_printf("%*s-->\n", 2 * ZT_G(observer_nesting_depth), "");

View File

@@ -0,0 +1,48 @@
--TEST--
GH-16319 (Fiber backtrace with null filename should not crash)
--EXTENSIONS--
zend_test
--INI--
zend_test.observer.enabled=1
zend_test.observer.show_init_backtrace=1
zend_test.observer.show_output=1
zend_test.observer.observe_all=1
zend_test.observer.show_opcode=0
opcache.jit=0
--FILE--
<?php
$fiber = new Fiber(function() {});
$fiber->start();
echo "Test completed without crash\n";
?>
--EXPECTF--
<!-- init %s -->
<!--
{main} %s
-->
<file %s>
<!-- init Fiber::__construct() -->
<!--
Fiber::__construct()
{main} %s
-->
<Fiber::__construct>
</Fiber::__construct>
<!-- init Fiber::start() -->
<!--
Fiber::start()
{main} %s
-->
<Fiber::start>
<!-- init {closure}() -->
<!--
{closure}()
{main} [no active file]
Fiber::start()
{main} %s
-->
<{closure}>
</{closure}>
</Fiber::start>
Test completed without crash
</file %s>