Skip to content

Potential use-after-free of AttributesProcessor in metric storage after MeterProvider shutdown #3456

@lalitb

Description

@lalitb

There is a potential use-after-free bug in the OpenTelemetry C++ SDK metrics implementation.

Problem:

  • Metric storage class(SyncMetricStorage) store a raw pointer to the AttributesProcessor instance, which is owned by the associated View.

  • The View (and its AttributesProcessor) is owned by the ViewRegistry, which is managed by the MeterContext and ultimately the MeterProvider.

  • When the MeterProvider is shut down or destroyed, the ViewRegistry and its Views are deleted, invalidating the AttributesProcessor pointer inside any metric storage objects.

  • If metric instruments are recorded after shutdown (especially from other threads, background tasks, or due to application logic errors), this leads to use-after-free, undefined behavior, and possible segmentation faults.

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