open-telemetry / open-telemetry/opentelemetry-cpp
[EXPORTER] OTLP HTTP exporter should not detach threads
@marcalff is already working on this.
Since Mar 10, 2025.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 632
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 75
Description
Context
In an instrumented application, the opentelemetry-cpp library static library is linked inside a bigger shared library, loaded and unloaded dynamically.
On cleanup, the code:
- calls shutdown on every signal provider
- releases the last references to every signal provider
- unload the shared library
Problem
The OTLP HTTP exporter background threads are detached, and may still run by the time the shared library is unloaded.
This causes the code of the opentelemetry-cpp library itself to be un mapped from the process space, while a thread is still running, leading to a crash.
Expected behavior
Never detach a thread.
Instead, properly join background threads to make sure the cleanup is complete, before returning from Shutdown.
This affects the OTLP HTTP exporter, as well as the OTLP FILE exporter.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.