Skip to content

[NO-TICKET] Add more memory leak testing for profiling using asan#3864

Merged
ivoanjo merged 2 commits into
masterfrom
ivoanjo/profiler-asan-ci
Aug 23, 2024
Merged

[NO-TICKET] Add more memory leak testing for profiling using asan#3864
ivoanjo merged 2 commits into
masterfrom
ivoanjo/profiler-asan-ci

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Aug 23, 2024

Copy link
Copy Markdown
Member

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?**

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
@ivoanjo ivoanjo requested review from a team as code owners August 23, 2024 11:24
@github-actions github-actions Bot added the profiling Involves Datadog profiling label Aug 23, 2024
@codecov-commenter

codecov-commenter commented Aug 23, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.85%. Comparing base (fe15909) to head (f43b485).
Report is 2605 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3864   +/-   ##
=======================================
  Coverage   97.85%   97.85%           
=======================================
  Files        1269     1269           
  Lines       75868    75868           
  Branches     3736     3736           
=======================================
+ Hits        74240    74244    +4     
+ Misses       1628     1624    -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@pr-commenter

pr-commenter Bot commented Aug 23, 2024

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2024-08-23 11:59:29

Comparing candidate commit f43b485 in PR branch ivoanjo/profiler-asan-ci with baseline commit fe15909 in branch ivoanjo/fixes-from-asan-branch.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 23 metrics, 2 unstable metrics.

@ivoanjo ivoanjo added dev/testing Involves testing processes (e.g. RSpec) dev/ci Involves CircleCI, GitHub Actions, or GitLab dev/internal Other internal work that does not need to be included in the changelog labels Aug 23, 2024
Base automatically changed from ivoanjo/fixes-from-asan-branch to master August 23, 2024 13:51
@ivoanjo ivoanjo merged commit 708bf9b into master Aug 23, 2024
@ivoanjo ivoanjo deleted the ivoanjo/profiler-asan-ci branch August 23, 2024 13:51
@github-actions github-actions Bot added this to the 2.4.0 milestone Aug 23, 2024
ivoanjo added a commit that referenced this pull request Nov 7, 2024
**What does this PR do?**

This PR re-enables the memory leak testing using the asan tool job in
CI.

For context, we added this testing in #3864 (more details about what
asan is can be found in that PR), but had to disable it in #3915
as the upstream Ruby builds we were using were broken and unavailable
for a while.

This has since been fixed upstream, and so let's re-enable this CI job.

In fact, upstream now officially allows these builds to be used, so
we no longer even need our fork of `setup-ruby` to enable them.

**Motivation:**

Improve our testing for native memory leaks.

**Additional Notes:**

N/A

**How to test the change?**

Validate that the "test-asan" is now running in CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev/ci Involves CircleCI, GitHub Actions, or GitLab dev/internal Other internal work that does not need to be included in the changelog dev/testing Involves testing processes (e.g. RSpec) profiling Involves Datadog profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants