Skip to content

Commit 595abee

Browse files
alexandre-dauboisiluuu1994
authored andcommitted
Fix phpGH-19548: remove ZEND_ACC_OVERRIDE on property inheritance only if it's not part of shared memory
Closes phpGH-19551
1 parent 4a1789c commit 595abee

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ PHP NEWS
1515
. Added support for configuring the URI parser for the FTP/FTPS as well as
1616
the SSL/TLS stream wrappers as described in
1717
https://wiki.php.net/rfc/url_parsing_api#plugability. (kocsismate)
18+
. Fixed bug GH-19548 (Shared memory violation on property inheritance).
19+
(alexandre-daubois)
1820

1921
- Filter:
2022
. Added support for configuring the URI parser for FILTER_VALIDATE_URL
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
GH-19548: Segfault when using inherited properties and opcache
3+
--FILE--
4+
<?php
5+
6+
interface I {
7+
public mixed $i { get; }
8+
}
9+
class P {
10+
public mixed $i;
11+
}
12+
13+
class C extends P implements I {}
14+
15+
echo "Test passed - no segmentation fault\n";
16+
17+
?>
18+
--EXPECT--
19+
Test passed - no segmentation fault
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
GH-19548: Segfault when using inherited properties and opcache (multiple properties)
3+
--FILE--
4+
<?php
5+
6+
interface I1 {
7+
public mixed $a { get; }
8+
public mixed $b { get; }
9+
}
10+
class P1 {
11+
public mixed $a;
12+
public mixed $b;
13+
}
14+
class C1 extends P1 implements I1 {}
15+
16+
interface I2 {
17+
public mixed $prop { get; }
18+
}
19+
class P2 {
20+
public mixed $prop;
21+
}
22+
class Q2 extends P2 {}
23+
class C2 extends Q2 implements I2 {}
24+
25+
echo "Multiple property test passed - no segmentation fault\n";
26+
27+
?>
28+
--EXPECT--
29+
Multiple property test passed - no segmentation fault

Zend/zend_inheritance.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,9 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
15641564
ZSTR_VAL(parent_info->ce->name));
15651565
}
15661566

1567-
child_info->flags &= ~ZEND_ACC_OVERRIDE;
1567+
if (child_info->ce == ce) {
1568+
child_info->flags &= ~ZEND_ACC_OVERRIDE;
1569+
}
15681570
}
15691571
} else {
15701572
zend_function **hooks = parent_info->hooks;

0 commit comments

Comments
 (0)