-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault when overriding sys.stderr #87826
Labels
3.7 (EOL)
end of life
3.8 (EOL)
end of life
3.9
only security fixes
3.10
only security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
Comments
This code crashes (reported by the one and only Matt Wozniski): import sys
class MyStderr:
def write(self, s):
sys.stderr = None
sys.stderr = MyStderr()
1/0 [1] 34112 segmentation fault ./python.exe lel.py |
pablogsal
added
3.7 (EOL)
end of life
3.8 (EOL)
end of life
3.9
only security fixes
3.10
only security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
labels
Mar 29, 2021
The problem is that https://github.com/python/cpython/blob/master/Python/pythonrun.c#L1074 doesn't take a strong reference to sys.stderr but code underneath can potentially release the GIL and remove the reference that keeps the object alive. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.7 (EOL)
end of life
3.8 (EOL)
end of life
3.9
only security fixes
3.10
only security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: