Skip to content

Commit 124c812

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-12392: Segmentation fault on SoapClient::__getTypes Fix GH-11121: ReflectionFiber segfault [ci skip] NEWS
2 parents 477aade + d8cd0f4 commit 124c812

File tree

7 files changed

+240
-7
lines changed

7 files changed

+240
-7
lines changed

NEWS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ PHP NEWS
55
- Core:
66
. Fixed double-free of non-interned enum case name. (ilutov)
77

8+
- Fiber:
9+
. Fixed bug GH-11121 (ReflectionFiber segfault). (danog, trowski, bwoebi)
10+
811
- Opcache:
912
. Added warning when JIT cannot be enabled. (danog)
13+
. Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since
14+
upgrading to 8.1.3 due to corrupt on-disk file cache). (turchanov)
15+
16+
- SOAP:
17+
. Fixed bug GH-12392 (Segmentation fault on SoapClient::__getTypes).
18+
(nielsdos)
1019

1120
12 Oct 2023, PHP 8.3.0RC4
1221

Zend/zend_fibers.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ static zend_always_inline zend_fiber_transfer zend_fiber_resume(zend_fiber *fibe
656656
{
657657
zend_fiber *previous = EG(active_fiber);
658658

659+
if (previous) {
660+
previous->execute_data = EG(current_execute_data);
661+
}
662+
659663
fiber->caller = EG(current_fiber_context);
660664
EG(active_fiber) = fiber;
661665

@@ -673,6 +677,7 @@ static zend_always_inline zend_fiber_transfer zend_fiber_suspend(zend_fiber *fib
673677
zend_fiber_context *caller = fiber->caller;
674678
fiber->previous = EG(current_fiber_context);
675679
fiber->caller = NULL;
680+
fiber->execute_data = EG(current_execute_data);
676681

677682
return zend_fiber_switch_to(caller, value, false);
678683
}
@@ -851,7 +856,6 @@ ZEND_METHOD(Fiber, suspend)
851856

852857
ZEND_ASSERT(fiber->context.status == ZEND_FIBER_STATUS_RUNNING || fiber->context.status == ZEND_FIBER_STATUS_SUSPENDED);
853858

854-
fiber->execute_data = EG(current_execute_data);
855859
fiber->stack_bottom->prev_execute_data = NULL;
856860

857861
zend_fiber_transfer transfer = zend_fiber_suspend(fiber, value);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
--TEST--
2+
GH-11121: Segfault when using ReflectionFiber
3+
--FILE--
4+
<?php
5+
function f() {
6+
Fiber::suspend();
7+
}
8+
9+
function g() {
10+
(new Fiber(function() {
11+
global $f;
12+
var_dump((new ReflectionFiber($f))->getTrace());
13+
}))->start();
14+
}
15+
16+
$f = new Fiber(function() { f(); max(...[1,2,3,4,5,6,7,8,9,10,11,12]); g(); });
17+
$f->start();
18+
$f->resume();
19+
20+
?>
21+
--EXPECTF--
22+
array(3) {
23+
[0]=>
24+
array(7) {
25+
["file"]=>
26+
string(%d) "%sReflectionFiber_bug_gh11121_1.php"
27+
["line"]=>
28+
int(10)
29+
["function"]=>
30+
string(5) "start"
31+
["class"]=>
32+
string(5) "Fiber"
33+
["object"]=>
34+
object(Fiber)#3 (0) {
35+
}
36+
["type"]=>
37+
string(2) "->"
38+
["args"]=>
39+
array(0) {
40+
}
41+
}
42+
[1]=>
43+
array(4) {
44+
["file"]=>
45+
string(%d) "%sReflectionFiber_bug_gh11121_1.php"
46+
["line"]=>
47+
int(13)
48+
["function"]=>
49+
string(1) "g"
50+
["args"]=>
51+
array(0) {
52+
}
53+
}
54+
[2]=>
55+
array(2) {
56+
["function"]=>
57+
string(9) "{closure}"
58+
["args"]=>
59+
array(0) {
60+
}
61+
}
62+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--TEST--
2+
GH-11121: Segfault when using ReflectionFiber
3+
--FILE--
4+
<?php
5+
6+
function f() {
7+
Fiber::suspend();
8+
}
9+
10+
function g() {
11+
(new Fiber(function() {
12+
global $f;
13+
var_dump((new ReflectionFiber($f))->getTrace());
14+
}))->start();
15+
}
16+
17+
$f = new Fiber(function() { f(); g(); });
18+
$f->start();
19+
$f->resume();
20+
21+
?>
22+
--EXPECTF--
23+
array(3) {
24+
[0]=>
25+
array(7) {
26+
["file"]=>
27+
string(%d) "%sReflectionFiber_bug_gh11121_2.php"
28+
["line"]=>
29+
int(11)
30+
["function"]=>
31+
string(5) "start"
32+
["class"]=>
33+
string(5) "Fiber"
34+
["object"]=>
35+
object(Fiber)#3 (0) {
36+
}
37+
["type"]=>
38+
string(2) "->"
39+
["args"]=>
40+
array(0) {
41+
}
42+
}
43+
[1]=>
44+
array(4) {
45+
["file"]=>
46+
string(%d) "%sReflectionFiber_bug_gh11121_2.php"
47+
["line"]=>
48+
int(14)
49+
["function"]=>
50+
string(1) "g"
51+
["args"]=>
52+
array(0) {
53+
}
54+
}
55+
[2]=>
56+
array(2) {
57+
["function"]=>
58+
string(9) "{closure}"
59+
["args"]=>
60+
array(0) {
61+
}
62+
}
63+
}

ext/soap/php_schema.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,17 +2261,23 @@ static void schema_type_fixup(sdlCtx *ctx, sdlTypePtr type)
22612261
schema_content_model_fixup(ctx, type->model);
22622262
}
22632263
if (type->attributes) {
2264-
zend_string *str_key;
2265-
zend_ulong index;
2264+
HashPosition pos;
2265+
zend_hash_internal_pointer_reset_ex(type->attributes, &pos);
22662266

2267-
ZEND_HASH_FOREACH_KEY_PTR(type->attributes, index, str_key, attr) {
2268-
if (str_key) {
2267+
while ((attr = zend_hash_get_current_data_ptr_ex(type->attributes, &pos)) != NULL) {
2268+
zend_string *str_key;
2269+
zend_ulong index;
2270+
2271+
if (zend_hash_get_current_key_ex(type->attributes, &str_key, &index, &pos) == HASH_KEY_IS_STRING) {
22692272
schema_attribute_fixup(ctx, attr);
2273+
zend_result result = zend_hash_move_forward_ex(type->attributes, &pos);
2274+
ZEND_ASSERT(result == SUCCESS);
22702275
} else {
22712276
schema_attributegroup_fixup(ctx, attr, type->attributes);
2272-
zend_hash_index_del(type->attributes, index);
2277+
zend_result result = zend_hash_index_del(type->attributes, index);
2278+
ZEND_ASSERT(result == SUCCESS);
22732279
}
2274-
} ZEND_HASH_FOREACH_END();
2280+
}
22752281
}
22762282
}
22772283

ext/soap/tests/gh12392.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
GH-12392 (Segmentation fault on SoapClient::__getTypes)
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
8+
$client = new SoapClient(__DIR__ . "/gh12392.wsdl", ['cache_wsdl' => WSDL_CACHE_NONE]);
9+
echo 'Client created!' . "\n";
10+
11+
$types = $client->__getTypes();
12+
echo 'Got types!' . "\n";
13+
14+
var_dump($types);
15+
16+
?>
17+
--EXPECT--
18+
Client created!
19+
Got types!
20+
array(1) {
21+
[0]=>
22+
string(62) "struct dummy {
23+
string foo;
24+
string a;
25+
string b;
26+
string c;
27+
}"
28+
}

ext/soap/tests/gh12392.wsdl

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<wsdl:definitions
3+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
4+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
5+
xmlns="http://schemas.xmlsoap.org/wsdl/"
6+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
7+
targetNamespace="http://xoev.de/schemata/xzufi/2_2_0">
8+
<wsdl:types>
9+
<xs:schema xmlns:ns="http://php.net" targetNamespace="http://php.net">
10+
<xs:attributeGroup name="c">
11+
<xs:attribute name="c" type="string" />
12+
</xs:attributeGroup>
13+
14+
<xs:attributeGroup name="b">
15+
<xs:attribute name="b" type="string" />
16+
</xs:attributeGroup>
17+
18+
<xs:attributeGroup name="a">
19+
<xs:attribute name="a" type="string" />
20+
<xs:attributeGroup ref="ns:b" />
21+
</xs:attributeGroup>
22+
23+
<xs:complexType name="dummy">
24+
<xs:sequence>
25+
<xs:element name="foo" type="string" />
26+
</xs:sequence>
27+
<xs:attributeGroup ref="ns:a" />
28+
<xs:attributeGroup ref="ns:c" />
29+
</xs:complexType>
30+
</xs:schema>
31+
</wsdl:types>
32+
33+
<!-- Below is a shortened copy of the test.wsdl, doesn't matter, only the types matter -->
34+
35+
<message name="AddRequest">
36+
<part name="x" type="xs:double" />
37+
</message>
38+
39+
<portType name="TestServicePortType">
40+
<operation name="Add">
41+
<input message="tns:AddRequest" />
42+
</operation>
43+
</portType>
44+
45+
<binding name="TestServiceBinding" type="tns:TestServicePortType">
46+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
47+
<operation name="Add">
48+
<soap:operation soapAction="Add" style="rpc" />
49+
<input>
50+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
51+
</input>
52+
</operation>
53+
</binding>
54+
55+
<service name="TestService">
56+
<port name="TestServicePort" binding="tns:TestServiceBinding">
57+
<soap:address location="http://linuxsrv.home/~dmitry/soap/soap_server.php" />
58+
</port>
59+
</service>
60+
61+
</wsdl:definitions>

0 commit comments

Comments
 (0)