Skip to content

Improve dd_library_loader dlclosing#3733

Merged
cataphract merged 2 commits into
masterfrom
glopes/dd-lib-loader-v2
Mar 26, 2026
Merged

Improve dd_library_loader dlclosing#3733
cataphract merged 2 commits into
masterfrom
glopes/dd-lib-loader-v2

Conversation

@cataphract

Copy link
Copy Markdown
Contributor

Description

Improve dd_library_loader dlclosing

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@cataphract cataphract requested a review from a team as a code owner March 26, 2026 12:31
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Mar 26, 2026

Copy link
Copy Markdown

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1048 Tests failed

testSearchPhpBinaries from integration.DDTrace\Tests\Integration\PHPInstallerTest   View in Datadog   (Fix with Cursor)
Risky Test
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:52
testSimplePushAndProcess from laravel-58-test.DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest   View in Datadog   (Fix with Cursor)
Risky Test
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:97
testSimplePushAndProcess from laravel-8x-test.DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest   View in Datadog   (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 69c54456000000007376958522b9c5ce
tid: 69c5445600000000
hexProcessTraceId: 7376958522b9c5ce
hexProcessSpanId: 23c0fc488e222fff
processTraceId: 8320001760659359182
processSpanId: 2576336375408373759
View all

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.68% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 36abf37 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@codecov-commenter

codecov-commenter commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.79%. Comparing base (10064f5) to head (36abf37).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3733      +/-   ##
==========================================
+ Coverage   68.78%   68.79%   +0.01%     
==========================================
  Files         166      166              
  Lines       19015    19015              
  Branches     1792     1792              
==========================================
+ Hits        13079    13081       +2     
  Misses       5124     5124              
+ Partials      812      810       -2     
Flag Coverage Δ
helper-rust-integration 78.82% <ø> (ø)
helper-rust-unit 49.17% <ø> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10064f5...36abf37. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Without the correct handle, glibc adds to dd_library_loader.c a
dependency on ddtrace.so and makes the symbol lookup procedure more
complicated than it needs to be.

(This still doesn't result in ddtrace.so being unloaded when dlclose()
is called on it because ddappsec.so depends on it still. This will be
fixed next.)
@cataphract cataphract force-pushed the glopes/dd-lib-loader-v2 branch from 27c11a0 to ceae2a4 Compare March 26, 2026 13:20
Comment thread loader/dd_library_loader.c Outdated
Comment on lines +425 to +428
// Use double-fork to avoid needing a background reaper thread.
// The intermediate child exits immediately and is reaped synchronously
// by the parent via waitpid(). The grandchild is reparented to init,
// which reaps it automatically after it calls execv().

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I forgot to mention this in the comment :-( - but we have users with "misbehaving" PID 1 scripts in docker containers, which do not reap and accumulate zombies.

That's why we don't double fork. So no, don't just replace that, we have to actually reap this ourselves.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because yes, double fork is the obvious solution to this problem, just not an acceptable one here.

Comment thread loader/dd_library_loader.c Outdated
// shutdown callbacks are run in the same order (not reverse) as they
// were loaded. So the callbacks for ddtrace/appsec/profiling will run
// AFTER this callback.
__auto_type ext_config = &ddloader_injected_ext_config[i];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a lint against __auto_type :-P

In all honesty, I just don't like it in C. It's easy to accidentally alias stuff to the wrong type in C - I think always writing the type is definitely superior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, we can stop using it once we move to C23, because auto has been repurposed there :p

@cataphract cataphract force-pushed the glopes/dd-lib-loader-v2 branch 2 times, most recently from ade5bd1 to 36abf37 Compare March 26, 2026 14:22
@pr-commenter

pr-commenter Bot commented Mar 26, 2026

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2026-03-26 15:42:02

Comparing candidate commit 36abf37 in PR branch glopes/dd-lib-loader-v2 with baseline commit 10064f5 in branch master.

Found 1 performance improvements and 3 performance regressions! Performance is the same for 188 metrics, 2 unstable metrics.

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟥 execution_time [+6.276µs; +10.904µs] or [+6.052%; +10.515%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟥 execution_time [+5.795µs; +7.605µs] or [+5.687%; +7.463%]

scenario:SamplingRuleMatchingBench/benchRegexMatching2-opcache

  • 🟥 execution_time [+10.447µs; +10.563µs] or [+674.368%; +681.865%]

scenario:TraceSerializationBench/benchSerializeTrace

  • 🟩 execution_time [-23.491µs; -10.409µs] or [-5.372%; -2.380%]

@cataphract cataphract force-pushed the glopes/dd-lib-loader-v2 branch from 36abf37 to 71013b9 Compare March 26, 2026 16:00
@cataphract cataphract enabled auto-merge March 26, 2026 16:00
@cataphract cataphract merged commit 0b0eab4 into master Mar 26, 2026
22 checks passed
@cataphract cataphract deleted the glopes/dd-lib-loader-v2 branch March 26, 2026 16:00
@github-actions github-actions Bot added profiling Relates to the Continuous Profiler tracing area:asm labels Mar 26, 2026
@github-actions github-actions Bot added this to the 1.18.0 milestone Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:asm profiling Relates to the Continuous Profiler tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants