mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140815: Fix faulthandler for invalid/freed frame (#140921)
faulthandler now detects if a frame or a code object is invalid or freed. Add helper functions: * _PyCode_SafeAddr2Line() * _PyFrame_SafeGetCode() * _PyFrame_SafeGetLasti() _PyMem_IsPtrFreed() now detects pointers in [-0xff, 0xff] range as freed.
This commit is contained in:
parent
08115d241a
commit
a84181c31b
6 changed files with 128 additions and 33 deletions
|
|
@ -274,8 +274,13 @@ extern void _PyLineTable_InitAddressRange(
|
|||
/** API for traversing the line number table. */
|
||||
PyAPI_FUNC(int) _PyLineTable_NextAddressRange(PyCodeAddressRange *range);
|
||||
extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
|
||||
// This is used in dump_frame() in traceback.c without an attached tstate.
|
||||
extern int _PyCode_Addr2LineNoTstate(PyCodeObject *co, int addr);
|
||||
|
||||
// Similar to PyCode_Addr2Line(), but return -1 if the code object is invalid
|
||||
// and can be called without an attached tstate. Used by dump_frame() in
|
||||
// Python/traceback.c. The function uses heuristics to detect freed memory,
|
||||
// it's not 100% reliable.
|
||||
extern int _PyCode_SafeAddr2Line(PyCodeObject *co, int addr);
|
||||
|
||||
|
||||
/** API for executors */
|
||||
extern void _PyCode_Clear_Executors(PyCodeObject *code);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue