Skip to content

gh-144316: Fix missing exception in _remote_debugging with debug=False#144442

Open
taegyunkim wants to merge 13 commits intopython:mainfrom
taegyunkim:gh-144316-get_stack_trace
Open

gh-144316: Fix missing exception in _remote_debugging with debug=False#144442
taegyunkim wants to merge 13 commits intopython:mainfrom
taegyunkim:gh-144316-get_stack_trace

Conversation

@taegyunkim
Copy link
Contributor

@taegyunkim taegyunkim commented Feb 3, 2026

  1. Adds missing PyErr_NoMemory() call when PyMem_RawMalloc() returned NULL.
  2. Adds missing PyErr_Format() calls before calling set_exception_cause macro
  3. Modifies set_exception_cause macro to assert an error is set.

@taegyunkim taegyunkim force-pushed the gh-144316-get_stack_trace branch from 7d1bb63 to 0f2d244 Compare February 3, 2026 19:50
@taegyunkim taegyunkim force-pushed the gh-144316-get_stack_trace branch from cffe58f to 66b060d Compare February 3, 2026 20:01
@taegyunkim taegyunkim marked this pull request as ready for review February 3, 2026 20:14
@taegyunkim taegyunkim requested a review from pablogsal as a code owner February 3, 2026 20:14
@pablogsal
Copy link
Member

This macro is intended to add context to an exception not to be the actual cause of the error. Doing this will mask actual bugs in the code where we are not setting exceptions properly in places that should catch it and fail. Unfortunately this is not only is a partial fix but it will hide errors. The correct solution is finding the error paths that are not properly handling errors and fix there (and perhaps chain).

@taegyunkim
Copy link
Contributor Author

taegyunkim commented Feb 4, 2026

@pablogsal Found PyMem_RawMalloc() call which didn't set PyErr when it returned NULL. Let me know if the changes to the macro look unnecessary.

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I think we should instead add assert(PyErr_Occurred()) in _set_debug_exception_cause instead.

@taegyunkim taegyunkim marked this pull request as draft February 4, 2026 20:37
@taegyunkim taegyunkim marked this pull request as ready for review February 4, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants