Bug report
Bug description:
Original gist: https://gist.github.com/devdanzin/a56b8cb579b1950b4206e8a42d6be650
Summary
Three bugs in the cross-interpreter subsystem:
- _ensure_notshareableerror (crossinterp_exceptions.h:85): Missing
return after _PyErr_SetRaisedException steals ctx ref. Falls through to code using freed pointer.
- _PyXI_UnwrapNotShareableError (crossinterp_data_lookup.h:102): Exception removed from thread state via
_PyErr_GetRaisedException, then _PyXI_InitFailure fails → exception leaked, thread error indicator cleared.
- _pop_preserved (crossinterp.c:2968): Inner
_PyXI_namespace *xidata shadows outer. goto error cleanup checks outer (NULL) variable → inner allocation leaked.
Reproducer (ref leak)
import _interpchannels as ch, sys
cid = ch.create()
before = sys.gettotalrefcount()
for i in range(10000):
try:
ch.send(cid, lambda: None, blocking=False)
except Exception:
pass
after = sys.gettotalrefcount()
ch.destroy(cid)
print(f"Leaked {after - before} refs (~{(after-before)//10000}/send)")
The third issue is already fixed by #147999
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Bug report
Bug description:
Original gist: https://gist.github.com/devdanzin/a56b8cb579b1950b4206e8a42d6be650
The third issue is already fixed by #147999
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs