Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions crates/vm/src/builtins/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,17 +967,22 @@ impl Py<FrameObject> {
let was_unset = canonical.cold().trace.lock().is_none();

// Set on the materialized FrameObject.
(*self.iframe().cold().trace.lock()).clone_from(&trace);
// Keep replaced traces alive until both copies are updated and no
// trace lock is held: their finalizers can access this frame again.
Comment on lines +970 to +971

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the existing materialized-frame comment

The deleted // Set on the materialized FrameObject. comment remains accurate because the new mem::replace still updates that frame’s trace storage. AGENTS.md explicitly says, “Do not delete or rewrite existing comments unless they are factually wrong or directly contradict the new code.” Neither exception applies here; retain the original comment alongside the new finalizer-lifetime explanation.

AGENTS.md reference: AGENTS.md:L165-L165

Useful? React with 👍 / 👎.

let previous = core::mem::replace(&mut *self.iframe().cold().trace.lock(), trace.clone());
// Also propagate to the live source iframe if this is a
// materialized copy of a stack-allocated frame, so pdb's
// f_trace assignment takes effect on the executing frame.
if !live.is_null() {
*unsafe { &*live }.cold().trace.lock() = trace;
}
let previous_live = if !live.is_null() {
core::mem::replace(&mut *unsafe { &*live }.cold().trace.lock(), trace)
} else {
None
};

if was_unset && trace_is_some {
canonical.sync_prev_line_from_lasti();
}
drop((previous, previous_live));
}

#[pygetset]
Expand Down
Loading