Skip to content

Commit 8900ea8

Browse files
Fix GH-19548: remove ZEND_ACC_OVERRIDE on property inheritance only if it's not part of shared memory
1 parent 4a1789c commit 8900ea8

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-19548: SEGV do_inherit_property zend_inheritance.c with opcache.protect_memory=1
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable_cli=1
7+
opcache.protect_memory=1
8+
--FILE--
9+
<?php
10+
11+
interface I {
12+
public mixed $i { get; }
13+
}
14+
class P {
15+
public mixed $i;
16+
}
17+
18+
class C extends P implements I {}
19+
20+
echo "Test passed - no segmentation fault\n";
21+
22+
?>
23+
--EXPECT--
24+
Test passed - no segmentation fault
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
GH-19548: SEGV do_inherit_property zend_inheritance.c with opcache.protect_memory=1 (multiple properties)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable_cli=1
7+
opcache.protect_memory=1
8+
--FILE--
9+
<?php
10+
11+
interface I1 {
12+
public mixed $a { get; }
13+
public mixed $b { get; }
14+
}
15+
class P1 {
16+
public mixed $a;
17+
public mixed $b;
18+
}
19+
class C1 extends P1 implements I1 {}
20+
21+
interface I2 {
22+
public mixed $prop { get; }
23+
}
24+
class P2 {
25+
public mixed $prop;
26+
}
27+
class Q2 extends P2 {}
28+
class C2 extends Q2 implements I2 {}
29+
30+
echo "Multiple property test passed - no segmentation fault\n";
31+
32+
?>
33+
--EXPECT--
34+
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)