Skip to content

Commit 52336c9

Browse files
authored
fix(prof): PHP 8.4 crash with opcache optimizer (#3038)
The optimizer puts a fake frame with a zeroed opline in accel_preload.
1 parent 82688ab commit 52336c9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

profiling/src/profiling/stack_walking.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,14 @@ mod detail {
209209
// allowed because it's only used on the frameless path
210210
#[allow(unused_variables)]
211211
if let Some(func) = unsafe { execute_data.func.as_ref() } {
212+
// It's possible that this is a fake frame put there by
213+
// the engine, see accel_preload on PHP 8.4 and the local
214+
// variable `fake_execute_data`. The frame is zeroed in
215+
// this case, so we can check for null.
212216
#[cfg(php_frameless)]
213-
if !func.is_internal() {
217+
if !func.is_internal() && !execute_data.opline.is_null() {
218+
// SAFETY: if it's not null, then it should be valid
219+
// or something else has messed up already.
214220
let opline = unsafe { &*execute_data.opline };
215221
match opline.opcode as u32 {
216222
ZEND_FRAMELESS_ICALL_0

0 commit comments

Comments
 (0)