[NO-TICKET] Small set of profiler cleanups from ASAN testing branch#3862
Merged
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. |
ivoanjo
added a commit
that referenced
this pull request
Aug 23, 2024
**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
AlexJF
approved these changes
Aug 23, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.rbMotivation:
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.