Skip to content

Enable LeakSanitizer (LSan) via -DSANITIZE=ON on Linux; add sanitized CI jobs#411

Merged
PJK merged 5 commits intomasterfrom
lsan-support
Mar 22, 2026
Merged

Enable LeakSanitizer (LSan) via -DSANITIZE=ON on Linux; add sanitized CI jobs#411
PJK merged 5 commits intomasterfrom
lsan-support

Conversation

@PJK
Copy link
Copy Markdown
Owner

@PJK PJK commented Mar 22, 2026

Fixes #365

Summary

  • Add -fsanitize=leak to the Debug sanitizer flags in CMakeLists.txt, guarded by NOT APPLE — Apple's LLVM drops standalone LSan support entirely; on Linux it is automatically included alongside ASan
  • Add a build-and-test-sanitized CircleCI job (Clang, Linux) that builds with SANITIZE=ON on every PR, giving continuous leak detection without Valgrind
  • Enable SANITIZE=ON in the existing macOS CI job for ASan + UBSan coverage (no LSan there, but catches memory errors and undefined behavior)

Test plan

  • Verified locally on ARM Mac (m4pro): build succeeds with SANITIZE=ON, no -fsanitize=leak flag applied, all 28 tests pass
  • Verified flag is absent from macOS compile commands (flags.make inspection)
  • Linux: new CI job will validate LSan detection end-to-end

🤖 Generated with Claude Code

PJK and others added 5 commits March 22, 2026 20:38
… CI jobs

- Add -fsanitize=leak to the Debug sanitizer flags, guarded by NOT APPLE
  (Apple's LLVM drops standalone LSan; on Linux it is included with ASan)
- Add build-and-test-sanitized CircleCI job (Clang, Linux) that runs with
  SANITIZE=ON on every PR, replacing Valgrind as the leak-detection path
- Enable SANITIZE=ON in the macOS CI job for ASan/UBSan coverage

Fixes #365

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adding -fsanitize=leak alongside -fsanitize=address links two LSan
runtimes which conflict at startup and cause crashes. ASan on Linux
x86_64/aarch64 already enables LSan by default (detect_leaks=1).
https://clang.llvm.org/docs/LeakSanitizer.html
Ubuntu 22.04 raised mmap_rnd_bits to 28, which conflicts with ASan's
fixed shadow memory offsets and causes random startup crashes across
different test binaries between runs.
google/sanitizers#1716
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.59%. Comparing base (d5222af) to head (9fddf34).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #411   +/-   ##
=======================================
  Coverage   99.59%   99.59%           
=======================================
  Files          20       20           
  Lines        1737     1737           
=======================================
  Hits         1730     1730           
  Misses          7        7           

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

@PJK PJK merged commit dc7fe29 into master Mar 22, 2026
19 checks passed
@PJK PJK deleted the lsan-support branch March 22, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLVM lsan configuration

1 participant