Skip to content

Commit

Permalink
fix(prof): PHP 8.4 crash with opcache optimizer (#3038)
Browse files Browse the repository at this point in the history
The optimizer puts a fake frame with a zeroed opline in accel_preload.
  • Loading branch information
morrisonlevi authored Jan 15, 2025
1 parent 82688ab commit 52336c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion profiling/src/profiling/stack_walking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 52336c9

Please sign in to comment.