-
Notifications
You must be signed in to change notification settings - Fork 192
Fix evaluation of variables from chained exception frames #2018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -404,6 +404,21 @@ def track(self, thread_id, frames_list, frame_custom_thread_id=None): | |
|
|
||
| self._frame_id_to_main_thread_id[frame_id] = thread_id | ||
|
|
||
| # Also track frames from chained exceptions (e.g. __cause__ / __context__) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot generated: Duplicated frame registration logic (Medium). The 5-line per-frame registration block ( |
||
| # so that variable evaluation works for chained exception frames displayed | ||
| # in the call stack. | ||
| chained = getattr(frames_list, 'chained_frames_list', None) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot generated: |
||
| while chained is not None and len(chained) > 0: | ||
| for frame in chained: | ||
| frame_id = id(frame) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot generated: |
||
| self._frame_id_to_frame[frame_id] = frame | ||
| _FrameVariable(self.py_db, frame, self._register_variable) | ||
| self._suspended_frames_manager._variable_reference_to_frames_tracker[frame_id] = self | ||
| frame_ids_from_thread.append(frame_id) | ||
|
|
||
| self._frame_id_to_main_thread_id[frame_id] = thread_id | ||
| chained = getattr(chained, 'chained_frames_list', None) | ||
|
|
||
| frame = None | ||
|
|
||
| def untrack_all(self): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot generated:
-419
Missing cycle detection on chained-frame walk (Medium-High). The
while chained is not Noneloop followschained_frames_listlinks without tracking visited nodes. If the exception chain is cyclic (possible pre-3.11 via__context__, or via manual__cause__assignment), this hangs the debugger. CPython's owntraceback.pyuses a_seenset for this reason. Suggested fix:Even if
create_frames_list_from_tracebackcurrently prevents cycles, this is cheap defense-in-depth.