[php-src] master: Merge branch 'PHP-8.6'
| From: | ndossche | Date: | Thu, 24 Sep 2026 16:47:13 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141506@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-09-24T18:46:59+02:00
Commit: https://github.com/php/php-src/commit/106ea51e4b49e7798079cab8343036d8530d2199
Raw diff: https://github.com/php/php-src/commit/106ea51e4b49e7798079cab8343036d8530d2199.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
Fix OSS-Fuzz #536440507: Immutable class incorrect assertion
fix aarch64 gcc preserve_none detection (#23883)
Changed paths:
A Zend/tests/lazy_objects/oss_fuzz_536440507.phpt
M Zend/Zend.m4
M Zend/zend_lazy_objects.c
Diff:
diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
index 6353ea2ec7a8..1f4e5e26f00e 100644
--- a/Zend/Zend.m4
+++ b/Zend/Zend.m4
@@ -513,7 +513,7 @@ uintptr_t __attribute__((preserve_none,noinline,used)) fun(uintptr_t a, uintptr_
return (uintptr_t)const3;
}
-uintptr_t __attribute__((preserve_none)) test(void) {
+uintptr_t __attribute__((preserve_none,noinline)) test(void) {
uintptr_t ret;
#if defined(__x86_64__)
@@ -531,7 +531,7 @@ uintptr_t __attribute__((preserve_none)) test(void) {
#endif
: "=a" (ret)
: "r" (const1), "r" (const2), "r" (key)
- : "r12", "r13"
+ : "r12", "r13", "memory", "cc"
);
#elif defined(__aarch64__)
__asm__ __volatile__(
@@ -547,7 +547,7 @@ uintptr_t __attribute__((preserve_none)) test(void) {
"mov %0, x0\n"
: "=r" (ret)
: "r" (const1), "r" (const2), "r" (key)
- : "x0", "x21", "x22", "x30"
+ : "x0", "x20", "x21", "x30", "memory",
"cc"
);
#else
# error
diff --git a/Zend/tests/lazy_objects/oss_fuzz_536440507.phpt
b/Zend/tests/lazy_objects/oss_fuzz_536440507.phpt
new file mode 100644
index 000000000000..02a1fcc69342
--- /dev/null
+++ b/Zend/tests/lazy_objects/oss_fuzz_536440507.phpt
@@ -0,0 +1,21 @@
+--TEST--
+OSS-Fuzz #536440507 (Immutable class incorrect assertion)
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+--FILE--
+<?php
+
+class C {
+ // Something that emits a warning so it can't be folded at compile time
+ public mixed $b = 340282366920938463454151235394913%435650;
+}
+$o = (new ReflectionClass(C::class))->newLazyGhost(function ($obj) {});
+var_dump($o->b);
+
+?>
+--EXPECTF--
+Deprecated: Implicit conversion from float 3.4028236692093845E+32 to int loses precision in %s on
line %d
+int(%s)
diff --git a/Zend/zend_lazy_objects.c b/Zend/zend_lazy_objects.c
index 5129a275c6df..d945a23d2b65 100644
--- a/Zend/zend_lazy_objects.c
+++ b/Zend/zend_lazy_objects.c
@@ -178,6 +178,18 @@ bool zend_lazy_object_decr_lazy_props(const zend_object *obj)
return info->lazy_properties_count == 0;
}
+/* See zend_update_class_constants(). */
+static zend_always_inline bool zend_class_constants_are_updated(const zend_class_entry *ce) {
+ if (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) {
+ return true;
+ }
+ if (ZEND_MAP_PTR(ce->mutable_data)) {
+ const zend_class_mutable_data *mutable_data = ZEND_MAP_PTR_GET_IMM(ce->mutable_data);
+ return mutable_data && (mutable_data->ce_flags & ZEND_ACC_CONSTANTS_UPDATED);
+ }
+ return false;
+}
+
/**
* Making objects lazy
*/
@@ -258,11 +270,9 @@ ZEND_API zend_object *zend_object_make_lazy(zend_object *obj,
return NULL;
}
- if (UNEXPECTED(!(reflection_ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) {
- if (UNEXPECTED(zend_update_class_constants(reflection_ce) != SUCCESS)) {
- ZEND_ASSERT(EG(exception));
- return NULL;
- }
+ if (UNEXPECTED(zend_update_class_constants(reflection_ce) != SUCCESS)) {
+ ZEND_ASSERT(EG(exception));
+ return NULL;
}
obj = zend_objects_new(reflection_ce);
@@ -382,7 +392,9 @@ ZEND_API zend_object *zend_lazy_object_mark_as_initialized(zend_object *obj)
zend_class_entry *ce = obj->ce;
- ZEND_ASSERT(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED);
+#if ZEND_DEBUG
+ ZEND_ASSERT(zend_class_constants_are_updated(ce));
+#endif
zval *default_properties_table = CE_DEFAULT_PROPERTIES_TABLE(ce);
zval *properties_table = obj->properties_table;
@@ -612,7 +624,9 @@ ZEND_API zend_object *zend_lazy_object_init(zend_object *obj)
zend_class_entry *ce = obj->ce;
- ZEND_ASSERT(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED);
+#if ZEND_DEBUG
+ ZEND_ASSERT(zend_class_constants_are_updated(ce));
+#endif
if (zend_object_is_lazy_proxy(obj)) {
return zend_lazy_object_init_proxy(obj);