Closed
Description
The following code reproducibly results in a segmentation fault:
#!/usr/bin/env python3.9
# pip install opentelemetry-sdk
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
BatchSpanProcessor,
ConsoleSpanExporter,
)
fd = open("foo.txt", "w")
tracer_provider = TracerProvider()
processor = BatchSpanProcessor(ConsoleSpanExporter(out=fd))
tracer_provider.add_span_processor(processor)
If you don't have a copy of Python 3.9 handy, you can use this Dockerfile:
FROM python:3.9.18-slim
RUN pip install opentelemetry-sdk
COPY file.py .
CMD ./file.py
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.