🌐 AI搜索 & 代理 主页
Skip to content

Commit c5307fb

Browse files
committed
Return only from the frame profiled
1 parent a9a9efe commit c5307fb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Python/ceval.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)