-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Garbage pointer dereference when using OTLP GRPC exporter with inacessible endpoint #3215
Comments
To be clear I think this bug is due to the unpredictable order of static destructors thus the simplest option is to intentionally leak. |
const opentelemetry::nostd::shared_ptr<LogHandler> &log_handler = \
GlobalLogHandler::GetLogHandler(); \
if (!log_handler) \
{ \
break; \
} \
std::stringstream tmp_stream; \
tmp_stream << message; \
log_handler->Handle(level, __FILE__, __LINE__, tmp_stream.str().c_str(), attributes); \ The destroying order of static local variables are predictable.The problem here may be the |
@tom-neara Could you please try #3221 to see if it occurs again. |
@owent this was the first thing I tried, but it doesn't prevent the crash. As can be seen in my gdb session, it's not the object pointer in the shared_ptr (%rax) which is zero, but the entry in the vtable (memory pointed to by %rax). The problem I believe is that |
You are right, I commit another approach which is just like some singleton's implementation to check the destroying. |
@owent great, I checked the latest version of your |
Describe your environment
x86_64, Ubuntu-22.04, bazel 7.40, opentelemetry-cpp 1.16.0 and 1.18.0
Steps to reproduce
Lazily setup otel like so (my setup had a lot more indirection, this code doesn't actually crash for me) and run with
OTEL_EXPORTER_OTLP_ENDPOINT=127.0.0.1:1337
or some other address that isn't a valid endpoint.In my actual environment where it reproduces, I'm launching python then calling into a pybind11 module which I built which calls
otel_tracer()
above and creates a few spans. The crash occurs in the grpc exporter aftermain
returns, see below.What is the expected behavior?
Program exits normally
What is the actual behavior?
Crash in https://github.com/open-telemetry/opentelemetry-cpp/blob/main/sdk/include/opentelemetry/sdk/common/global_log_handler.h#L162
Additional context
gdb session:
Applying this patch prevents the destruction of the global handler and thus prevents it from crashing
The text was updated successfully, but these errors were encountered: