File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -2006,8 +2006,11 @@ _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame * frame)
20062006{
20072007 // Update last_profiled_frame for remote profiler frame caching.
20082008 // By this point, tstate->current_frame is already set to the parent frame.
2009- // The guarded check avoids writes when profiling is not active (predictable branch).
2010- if (tstate -> last_profiled_frame != NULL ) {
2009+ // Only update if we're popping the exact frame that was last profiled.
2010+ // This avoids corrupting the cache when transient frames (called and returned
2011+ // between profiler samples) update last_profiled_frame to addresses the
2012+ // profiler never saw.
2013+ if (tstate -> last_profiled_frame != NULL && tstate -> last_profiled_frame == frame ) {
20112014 tstate -> last_profiled_frame = tstate -> current_frame ;
20122015 }
20132016
You can’t perform that action at this time.
0 commit comments