Skip to content

[EXPORTER] OTLP HTTP exporter should not detach threads #3295

@marcalff

Description

@marcalff

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions