From 595abeef3fe0cb131a7825447a318cd5b60e068a Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 22 Aug 2025 10:31:01 +0200 Subject: [PATCH] Fix GH-19548: remove ZEND_ACC_OVERRIDE on property inheritance only if it's not part of shared memory Closes GH-19551 --- NEWS | 2 ++ Zend/tests/property_hooks/gh19548.phpt | 19 ++++++++++++++ Zend/tests/property_hooks/gh19548_002.phpt | 29 ++++++++++++++++++++++ Zend/zend_inheritance.c | 4 ++- 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/property_hooks/gh19548.phpt create mode 100644 Zend/tests/property_hooks/gh19548_002.phpt diff --git a/NEWS b/NEWS index abd2590c646..1e1891bf83c 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ PHP NEWS . Added support for configuring the URI parser for the FTP/FTPS as well as the SSL/TLS stream wrappers as described in https://wiki.php.net/rfc/url_parsing_api#plugability. (kocsismate) + . Fixed bug GH-19548 (Shared memory violation on property inheritance). + (alexandre-daubois) - Filter: . Added support for configuring the URI parser for FILTER_VALIDATE_URL diff --git a/Zend/tests/property_hooks/gh19548.phpt b/Zend/tests/property_hooks/gh19548.phpt new file mode 100644 index 00000000000..d34ed0a74bb --- /dev/null +++ b/Zend/tests/property_hooks/gh19548.phpt @@ -0,0 +1,19 @@ +--TEST-- +GH-19548: Segfault when using inherited properties and opcache +--FILE-- + +--EXPECT-- +Test passed - no segmentation fault diff --git a/Zend/tests/property_hooks/gh19548_002.phpt b/Zend/tests/property_hooks/gh19548_002.phpt new file mode 100644 index 00000000000..bba006b8103 --- /dev/null +++ b/Zend/tests/property_hooks/gh19548_002.phpt @@ -0,0 +1,29 @@ +--TEST-- +GH-19548: Segfault when using inherited properties and opcache (multiple properties) +--FILE-- + +--EXPECT-- +Multiple property test passed - no segmentation fault diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index bbc7a767e1b..8679a53e8ff 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1564,7 +1564,9 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke ZSTR_VAL(parent_info->ce->name)); } - child_info->flags &= ~ZEND_ACC_OVERRIDE; + if (child_info->ce == ce) { + child_info->flags &= ~ZEND_ACC_OVERRIDE; + } } } else { zend_function **hooks = parent_info->hooks;