From 5e9654be0337d4778f3ab93bdfce228c12d135f6 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 22 Oct 2022 21:31:51 +0000 Subject: [PATCH] Fixed missing run_time_cache for preloaded arena allocated internal functions This effectively affected all preloaded enums, leading them to possibly share a run_time_cache__ptr slot with unrelated functions. (Given that these were not set again.) This bugfix is not accompanied by a test, due to how hard to trigger it was and getting a crash also depends a lot on the precise alignment of whether a cache entry accidentally overlapping has been used etc. --- NEWS | 1 + ext/opcache/zend_persist.c | 1 + 2 files changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 0e733b94bf2..eb1c84972e1 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ PHP NEWS evaluation with extra named params). (Arnaud) . Fixed bug GH-9801 (Generator crashes when memory limit is exceeded during initialization). (Arnaud) + . Fixed a bug with preloaded enums possibly segfaulting. (Bob) - MySQLnd: . Fixed potential heap corruption due to alignment mismatch. (cmb) diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 0e2eb0377a8..91765676b38 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -723,6 +723,7 @@ static void zend_persist_class_method(zval *zv, zend_class_entry *ce) } } } + ZEND_MAP_PTR_NEW(op_array->run_time_cache); } } return;