-
Notifications
You must be signed in to change notification settings - Fork 381
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
[NO-TICKET] Small set of profiler cleanups from ASAN testing branch #3862
Conversation
ASAN doesn't support RTLD_DEEPBIND (it outputs an error saying that explicitly), so we need to omit it on those builds.
When building libdatadog with ASAN, not having empty strings for mapping strings made libdatadog fail with `ddog_prof_Profile_add failed: incomplete utf-8 byte sequence from index 0`. Now I strongly suspect in practice this isn't an issue, but it's easy to clean/fix, and makes it easier to experiment with ASAN builds.
This fixes the clang warning: > warning: implicit conversion from 'unsigned long' to 'double' changes > value from 18446744073709551615 to 18446744073709551616 > [-Wimplicit-const-int-float-conversion] Rather than getting a bit fancy, I decided to simplify by using UINT32_MAX instead, which is already quite an unrealistic value for a sampling interval.
This fixes the clang warning: > warning: implicit conversion loses integer precision: 'unsigned long' > to 'unsigned int' [-Wshorten-64-to-32] I've made the conversion explicit now, and also made sure no overflow can happen.
Now that dd-trace-rb is Ruby 2.5+, we can drop our own home-baked version and use mkmf's `append_cflags` directly. (The `libdatadog_api` extension was already using this new helper as well)
This fixes the clang warning > warning: implicit conversion loses integer precision: 'uintptr_t' > (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## ivoanjo/check-profiler-memleaks #3862 +/- ##
================================================================
Coverage 97.85% 97.85%
================================================================
Files 1269 1269
Lines 75868 75868
Branches 3736 3736
================================================================
+ Hits 74237 74240 +3
+ Misses 1631 1628 -3 ☔ View full report in Codecov by Sentry. |
BenchmarksBenchmark execution time: 2024-08-22 15:21:02 Comparing candidate commit fe15909 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 23 metrics, 2 unstable metrics. |
**What does this PR do?** This PR builds atop the work from #3852 and #3862 to enable running the profiler test suite using the AddressSanitizer ("asan") tool (see https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer ). This check will enable us to find bugs in the profiler that may not be otherwise caught. **Motivation:** Improve validation of the profiler native extension. **Additional Notes:** The "asan" tool is built into the clang compiler toolchain, and needs Ruby to be built with a special configuration. The special configuration is not yet available in the upstream `ruby/setup-ruby` github action, so I needed to fork it and push a small tweak to make it available. (The Ruby builds were added in ruby/ruby-dev-builder#10 ). **How to test the change?** Here's a passing CI run: https://github.com/DataDog/dd-trace-rb/actions/runs/10524502494/job/29161364590 I've also tested locally by adding a memory leak (e.g. for instance commenting out `ddog_Vec_Tag_drop(tags);` in `http_transport.c` and confirmed the issue was flagged.
**What does this PR do?** This PR builds atop the work from #3852 and #3862 to enable running the profiler test suite using the AddressSanitizer ("asan") tool (see https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer ). This check will enable us to find bugs in the profiler that may not be otherwise caught. **Motivation:** Improve validation of the profiler native extension. **Additional Notes:** The "asan" tool is built into the clang compiler toolchain, and needs Ruby to be built with a special configuration. The special configuration is not yet available in the upstream `ruby/setup-ruby` github action, so I needed to fork it and push a small tweak to make it available. (The Ruby builds were added in ruby/ruby-dev-builder#10 ). **How to test the change?** Here's a passing CI run: https://github.com/DataDog/dd-trace-rb/actions/runs/10524502494/job/29161364590 I've also tested it by adding a memory leak (e.g. for instance commenting out `ddog_Vec_Tag_drop(tags);` in `http_transport.c` and confirmed the issue was flagged. Here's the failing CI run: https://github.com/DataDog/dd-trace-rb/actions/runs/10524803685/job/29162274392
What does this PR do?
I've been experimenting with building the profiler with AddressSanitizer (aka ASAN).
So far, I did not discover any issue in the profiler, but I ended up collecting a few tweaks and improvements:
extconf.rb
Motivation:
Since I'm not sure I'll have the full ASAN testing working on CI soon, I decided to open up a PR with the fixes I had collected.
Additional Notes:
Although the PR is not big/particularly complex, it may be even easier to review commit-by-commit.
This PR is atop #3852 as it was easier for me to test all of the improvements together, but they are otherwise unrelated. I'll wait until #3852 is merged to master before merging this one.
How to test the change?
Validate that CI still passes, and with no compilation warnings. You can also try compiling the profiler locally with clang and confirm that there are also no warnings emitted by clang.