Commit 2dbcf91
committed
gh-158539: Fix exception mode missing handlers in generators/coroutines
The sampling profiler's exception mode decided whether a thread was
handling an exception by reading the embedded PyThreadState.exc_state.
Generators, coroutines and async generators repoint tstate->exc_info
at their own _PyErr_StackItem while they run, so an except block
running in one of them (or in a function they call) stored the
exception in that item instead, and was never sampled.
Follow tstate->exc_info and its previous_item chain, mirroring
_PyErr_GetTopmostException(), and export the two debug offsets needed
to walk the chain from remote memory. The common case where exc_info
points at the embedded exc_state keeps the existing zero-extra-read
fast path.1 parent a4f28a5 commit 2dbcf91
5 files changed
Lines changed: 466 additions & 10 deletions
File tree
- Include/internal
- Lib/test
- Misc/NEWS.d/next/Library
- Modules/_remote_debugging
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| |||
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
| 309 | + | |
307 | 310 | | |
308 | 311 | | |
309 | 312 | | |
| 313 | + | |
310 | 314 | | |
311 | 315 | | |
312 | 316 | | |
| |||
0 commit comments