You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python <=3.9 segmentation fault in code snippet #117090
The following conditions need to be met for the segmentation fault to happen:
Python 3.9.18 or older (does not happen with Python 3.10 or newer)
fd must not be closed (does not happen if fd.close() is run at the end)
I could reproduce this segfault on both macOS Sonoma 14.3.1 and Ubuntu Linux 23.10.
I realize that 3.8 and 3.9 are no longer in the "bugfix" phase but the segfault may have security implications, which is why I decided to open this issue. Please feel free to close if it's not helpful.
Segfault is sometimes security issue, not always, but the more important thing is - can you repro this without opentelemetry? If it's a CPython issue then it should be reproducible without any 3rd party code.
Reacted by Serhiy Storchaka, Eric V. Smith and Zachary Ware
But I am not sure about similar SEGV is not possible anymore.
ResourceWarning for unclosed files are happened during interpreter shutdown often.
So warning code would be more defensive. Instead of assert(global != NULL), it can be if (global == NULL) { goto handle_error; }
I checked finalization code and I can not find any way to emit ResourceWarning after Py_CLEAR(interp->sysdict); in interpreter_clean().
So I think this issue is really fixed in Python 3.10+ by #21605 .
Activity
gaogaotiantian commentedon Mar 20, 2024
Segfault is sometimes security issue, not always, but the more important thing is - can you repro this without
opentelemetry? If it's a CPython issue then it should be reproducible without any 3rd party code.NullHypothesis commentedon Mar 20, 2024
I'm unable to spend more cycles on this but I'll create an OpenTelemetry issue. If that results in something useful, I'll re-open.
methane commentedon Mar 21, 2024
I can reproduce it without otel. ref
This issue caused by this code is called during late interpreter shutdown.
cpython/Python/_warnings.c
Line 916 in 1f8b24e
This issue is fixed by this commit in Python 3.10.
register_at_forkis cleared before sysdict.#21605
But I am not sure about similar SEGV is not possible anymore.
ResourceWarning for unclosed files are happened during interpreter shutdown often.
So warning code would be more defensive. Instead of
assert(global != NULL), it can beif (global == NULL) { goto handle_error; }methane commentedon Mar 21, 2024
I checked finalization code and I can not find any way to emit ResourceWarning after
Py_CLEAR(interp->sysdict);ininterpreter_clean().So I think this issue is really fixed in Python 3.10+ by #21605 .