-
Notifications
You must be signed in to change notification settings - Fork 705
Python 3.9 segfault in minimal tracing snippet #3801
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
Comments
This is a bug in Python. Python tried to show "unclosed file" ResourceWarning, but I'm not sure this would be fixed because 3.9 is in security fix only mode.
|
I investigated that is this issue fixed or just hidden by some random reason. |
FYI, minimum reproducible code without otel: import os, time
f = open("foo.txt", "w")
class C:
def __init__(self):
self.f = f
os.register_at_fork(after_in_child=self.atfork)
def atfork(self):
print("atfork")
c=C()
del c, f |
Great work, thanks @methane! I also reported this in Python's issue tracker (python/cpython#117090) but closed the issue because I didn't have a reproducible snippet without third-party code. As you said, this is unlikely to get fixed by Python and cannot be fixed by OpenTelemetry, so we might as well close this issue. |
Root cause is unclosed file. You can fix it by subclassing ConsoleSpanExporter and implement class FileSpanExporter(ConsoleSpanExporter):
def shutdown(self):
self.out.close() |
Thanks again for your careful investigation of this issue, @methane. |
The following code reproducibly results in a segmentation fault:
If you don't have a copy of Python 3.9 handy, you can use this Dockerfile:
Describe your environment
This happens on both macOS (Sonoma 14.3.1) and Linux (Ubuntu 23.10). As far as I can tell, Python <=3.9 is affected but not Python >=3.10.
Steps to reproduce
The segfault occurs under the following conditions:
BatchSpanProcessor
must be used (does not happen withSimpleSpanProcessor
)out=fd
must be passed toConsoleSpanExporter
(does not happen without)fd
must not be closed at the end of the file (does not happen withfd.close()
)What is the expected behavior?
No segfault.
What is the actual behavior?
Segfault.
Additional context
I realize that Python 3.9 is close to its end-of-life but I figured that there's merit in reporting this issue regardless.
The text was updated successfully, but these errors were encountered: