Skip to content

Commit 8877bef

Browse files
committed
Fix top-level frame from getting out of sync on happy path
1 parent cc7f6f5 commit 8877bef

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Zend/zend_observer.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ zend_llist zend_observer_error_callbacks;
4444
int zend_observer_fcall_op_array_extension = -1;
4545

4646
ZEND_TLS zend_arena *fcall_handlers_arena = NULL;
47+
ZEND_TLS zend_execute_data *first_observed_frame = NULL;
4748
ZEND_TLS zend_execute_data *current_observed_frame = NULL;
4849

4950
// Call during minit/startup ONLY
5051
ZEND_API void zend_observer_fcall_register(zend_observer_fcall_init init) {
51-
/* We don't want to get an extension handle unless an ext installs an observer */
5252
if (!ZEND_OBSERVER_ENABLED) {
53+
/* We don't want to get an extension handle unless an ext installs an observer */
5354
zend_observer_fcall_op_array_extension =
5455
zend_get_op_array_extension_handle("Zend Observer");
5556

@@ -161,6 +162,9 @@ static void ZEND_FASTCALL _zend_observe_fcall_begin(zend_execute_data *execute_d
161162
return;
162163
}
163164

165+
if (first_observed_frame == NULL) {
166+
first_observed_frame = execute_data;
167+
}
164168
current_observed_frame = execute_data;
165169

166170
end = fcall_data->end;
@@ -212,7 +216,12 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_end(
212216
}
213217
}
214218

215-
current_observed_frame = execute_data->prev_execute_data;
219+
if (first_observed_frame == execute_data) {
220+
first_observed_frame = NULL;
221+
current_observed_frame = NULL;
222+
} else {
223+
current_observed_frame = execute_data->prev_execute_data;
224+
}
216225
}
217226

218227
ZEND_API void zend_observer_fcall_end_all(void)

0 commit comments

Comments
 (0)