From bdbb427aa1fb3c08b415ec18d609f4a26b0cdff6 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Wed, 15 Jan 2025 10:53:20 -0700 Subject: [PATCH] fix(prof): PHP 8.4 crash with opcache optimizer (#3038) The optimizer puts a fake frame with a zeroed opline in accel_preload. --- profiling/src/profiling/stack_walking.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/profiling/src/profiling/stack_walking.rs b/profiling/src/profiling/stack_walking.rs index 38e1e6b575..c6ab53f9a0 100644 --- a/profiling/src/profiling/stack_walking.rs +++ b/profiling/src/profiling/stack_walking.rs @@ -209,8 +209,14 @@ mod detail { // allowed because it's only used on the frameless path #[allow(unused_variables)] if let Some(func) = unsafe { execute_data.func.as_ref() } { + // It's possible that this is a fake frame put there by + // the engine, see accel_preload on PHP 8.4 and the local + // variable `fake_execute_data`. The frame is zeroed in + // this case, so we can check for null. #[cfg(php_frameless)] - if !func.is_internal() { + if !func.is_internal() && !execute_data.opline.is_null() { + // SAFETY: if it's not null, then it should be valid + // or something else has messed up already. let opline = unsafe { &*execute_data.opline }; match opline.opcode as u32 { ZEND_FRAMELESS_ICALL_0