Skip to content

[API] NoopLogger causes segfault #2656

@yurishkuro

Description

@yurishkuro

Describe your environment v1.14.2

Steps to reproduce

#include "opentelemetry/logs/provider.h"

int main(int argc, char* argv[]) {
  auto logs_provider = opentelemetry::v1::logs::Provider::GetLoggerProvider();
  auto logger = logs_provider->GetLogger("test");
  auto sample = logger->CreateLogRecord();
  sample->SetAttribute("some key", "some value");
  logger->EmitLogRecord(std::move(sample));
  return 0;
}

What is the expected behavior?
Program should run successfully.

What is the actual behavior?
SEGV at sample->SetAttribute because sample is null.

Additional context

nostd::unique_ptr<LogRecord> CreateLogRecord() noexcept override { return nullptr; }

The NoopLogger is supposed to return usable objects, not a nullptr.

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