Capture proxy related environment variables at Curl client construction to avoid crash#328
Conversation
…ion to avoid calls to getenv() from libcurl in the worker thread, leading to crashes in some cases
This comment has been minimized.
This comment has been minimized.
dd05555 to
f0bce1d
Compare
BenchmarksBenchmark execution time: 2026-06-12 18:31:48 Comparing candidate commit 6d126a4 in PR branch Found 3 performance improvements and 0 performance regressions! Performance is the same for 5 metrics, 0 unstable metrics.
|
zacharycmontoya
left a comment
There was a problem hiding this comment.
LGTM with one small refactor comment
Description
Read the proxy related environment variables when the
Curlclient is created (inCurlImplconstructor), and, later, pass the values tolibcurlexplicitly on each request (inCurlImpl::post()).Motivation
In some (new) tests for the Datadog Nginx module, we get crashes during shutdown.
This is because the tracer's
libcurlbackground thread reads proxy environment variables viagetenv()on every new connection. But when Nginx shuts down, it changes its worker's process title, which rewrites its environment. This leads to a segfault due to a race condition.Additional Notes
This mirrors the approach used in
dd-trace-php(in ddtrace_comes_minit_proxy_env()).I cleaned a bit the surrounding code, notably by extracting
CurlImpl::configure_handle()fromCurlImpl::post().