mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix segfault when using ReflectionFiber (fixes #10439)
This commit is contained in:
commit
f1818d726f
2
NEWS
2
NEWS
@ -67,6 +67,8 @@ PHP NEWS
|
||||
- Reflection:
|
||||
. Fixed bug GH-10623 (Reflection::getClosureUsedVariables opcode fix with
|
||||
variadic arguments). (nielsdos)
|
||||
. Fix Segfault when using ReflectionFiber suspended by an internal function.
|
||||
(danog)
|
||||
|
||||
- Session:
|
||||
. Fixed ps_files_cleanup_dir() on failure code paths with -1 instead of 0 as
|
||||
|
@ -7085,7 +7085,13 @@ ZEND_METHOD(ReflectionFiber, getExecutingLine)
|
||||
prev_execute_data = fiber->execute_data->prev_execute_data;
|
||||
}
|
||||
|
||||
RETURN_LONG(prev_execute_data->opline->lineno);
|
||||
while (prev_execute_data && (!prev_execute_data->func || !ZEND_USER_CODE(prev_execute_data->func->common.type))) {
|
||||
prev_execute_data = prev_execute_data->prev_execute_data;
|
||||
}
|
||||
if (prev_execute_data && prev_execute_data->func && ZEND_USER_CODE(prev_execute_data->func->common.type)) {
|
||||
RETURN_LONG(prev_execute_data->opline->lineno);
|
||||
}
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
ZEND_METHOD(ReflectionFiber, getExecutingFile)
|
||||
@ -7103,7 +7109,13 @@ ZEND_METHOD(ReflectionFiber, getExecutingFile)
|
||||
prev_execute_data = fiber->execute_data->prev_execute_data;
|
||||
}
|
||||
|
||||
RETURN_STR_COPY(prev_execute_data->func->op_array.filename);
|
||||
while (prev_execute_data && (!prev_execute_data->func || !ZEND_USER_CODE(prev_execute_data->func->common.type))) {
|
||||
prev_execute_data = prev_execute_data->prev_execute_data;
|
||||
}
|
||||
if (prev_execute_data && prev_execute_data->func && ZEND_USER_CODE(prev_execute_data->func->common.type)) {
|
||||
RETURN_STR_COPY(prev_execute_data->func->op_array.filename);
|
||||
}
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
ZEND_METHOD(ReflectionFiber, getCallable)
|
||||
|
@ -874,9 +874,9 @@ final class ReflectionFiber
|
||||
|
||||
public function getFiber(): Fiber {}
|
||||
|
||||
public function getExecutingFile(): string {}
|
||||
public function getExecutingFile(): ?string {}
|
||||
|
||||
public function getExecutingLine(): int {}
|
||||
public function getExecutingLine(): ?int {}
|
||||
|
||||
public function getCallable(): callable {}
|
||||
|
||||
|
8
ext/reflection/php_reflection_arginfo.h
generated
8
ext/reflection/php_reflection_arginfo.h
generated
@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: a531c9132b4ac3d3196570ae6dda52b8f6a4f488 */
|
||||
* Stub hash: b247a6a7fed18525f611001da064da58e7583501 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)
|
||||
@ -593,9 +593,11 @@ ZEND_END_ARG_INFO()
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ReflectionFiber_getFiber, 0, 0, Fiber, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_class_ReflectionFiber_getExecutingFile arginfo_class_ReflectionFunction___toString
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionFiber_getExecutingFile, 0, 0, IS_STRING, 1)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_class_ReflectionFiber_getExecutingLine arginfo_class_ReflectionAttribute_getTarget
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionFiber_getExecutingLine, 0, 0, IS_LONG, 1)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionFiber_getCallable, 0, 0, IS_CALLABLE, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
31
ext/reflection/tests/ReflectionFiber_notrace_1.phpt
Normal file
31
ext/reflection/tests/ReflectionFiber_notrace_1.phpt
Normal file
@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
ReflectionFiber should not segfault when inspecting fibers with no stack frames before suspend
|
||||
--FILE--
|
||||
<?php
|
||||
$f = new Fiber(Fiber::suspend(...));
|
||||
$f->start();
|
||||
|
||||
$reflection = new ReflectionFiber($f);
|
||||
|
||||
var_dump($reflection->getExecutingFile());
|
||||
var_dump($reflection->getExecutingLine());
|
||||
var_dump($reflection->getTrace());
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
NULL
|
||||
NULL
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(4) {
|
||||
["function"]=>
|
||||
string(7) "suspend"
|
||||
["class"]=>
|
||||
string(5) "Fiber"
|
||||
["type"]=>
|
||||
string(2) "::"
|
||||
["args"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
}
|
61
ext/reflection/tests/ReflectionFiber_notrace_2.phpt
Normal file
61
ext/reflection/tests/ReflectionFiber_notrace_2.phpt
Normal file
@ -0,0 +1,61 @@
|
||||
--TEST--
|
||||
ReflectionFiber should not segfault when inspecting fibers where the previous stack frame is a native function
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
namespace test;
|
||||
|
||||
$f = new \Fiber(fn() => call_user_func(["Fiber", "suspend"]));
|
||||
$f->start();
|
||||
|
||||
$reflection = new \ReflectionFiber($f);
|
||||
|
||||
var_dump($reflection->getExecutingFile());
|
||||
var_dump($reflection->getExecutingLine());
|
||||
var_dump($reflection->getTrace());
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(%d) "%sReflectionFiber_notrace_2.php"
|
||||
int(5)
|
||||
array(3) {
|
||||
[0]=>
|
||||
array(4) {
|
||||
["function"]=>
|
||||
string(7) "suspend"
|
||||
["class"]=>
|
||||
string(5) "Fiber"
|
||||
["type"]=>
|
||||
string(2) "::"
|
||||
["args"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[1]=>
|
||||
array(4) {
|
||||
["file"]=>
|
||||
string(%d) "%sReflectionFiber_notrace_2.php"
|
||||
["line"]=>
|
||||
int(5)
|
||||
["function"]=>
|
||||
string(14) "call_user_func"
|
||||
["args"]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(5) "Fiber"
|
||||
[1]=>
|
||||
string(7) "suspend"
|
||||
}
|
||||
}
|
||||
}
|
||||
[2]=>
|
||||
array(2) {
|
||||
["function"]=>
|
||||
string(14) "test\{closure}"
|
||||
["args"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user