Py3.12: Getting stack traces can crash the interpreter #1969
Labels
Level: help wanted
The maintainers could use help
Platform: POSIX
PyVer: python3
Affects Python 3
Type: Bug
Identified as a bug; needs a code change to fix
With the current state of gevent on 3.12b3 (gevent 23.7.0, greenlet 3.0a1),
test__util.py
crashes the interpreter while executing pure-Python code that callstraceback.format_stack()
. This test exercises theformat_run_info
function, which looks for any reachable greenlet objects (usinggc.get_objects()
) and prints their stacks, starting with thegreenlet.gr_frame
frame object.The crash happens when the
traceback
code executesf = f.f_back
, and the crash is insidePyObject_GetAttr
.This suggests that the frame object is invalid or corrupted, which in turn suggests a greenlet issue, but:
Perhaps
gc.get_objects
is finding greenlets that it shouldn't? Perhapsgreenlet
needs to be more proactive about settinggr_frame
to None?This has been observed on macOS.
On Linux, instead of crashing,
f = f.f_back
was producing anAttributeError: dict has no attribute f_back
. Not sure how that could happen either baring memory corruption of some sort.(Windows is not yet testing 3.12, so I don't know what happens there.)
For the release of gevent 23.7.0, I have disabled stack traces for greenlets in
util.GreenletTree.__render_tb
as a workaround. This is not ideal, obviously.The text was updated successfully, but these errors were encountered: