Skip to content

Python <=3.9 segmentation fault in code snippet #117090

Closed as not planned
Closed as not planned
@NullHypothesis

Description

@NullHypothesis

Bug report

Bug description:

The following code snippet results in a segmentation fault in Python 3.8 and 3.9, but not 3.10 and newer:

#!/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)

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.

CPython versions tested on:

3.8, 3.9, 3.10, 3.13

Operating systems tested on:

Linux, macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions