Skip to content

Wire up LeakSanitizer support - #828

Merged
helly25 merged 1 commit into
bazel-contrib:masterfrom
helly25:fix-826-lsan
Aug 16, 2026
Merged

helly25 merged 1 commit into
bazel-contrib:masterfrom
helly25:fix-826-lsan

Conversation

@helly25

@helly25 helly25 commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Fixes #826.

Summary

Wire rules_cc's stock lsan feature into the same augmentation path as asan, ubsan, and tsan:

  • add //toolchain/config:use_lsan and include it in use_common_sanitizer
  • add the Darwin libclang_rt.lsan_osx_dynamic.dylib filegroup and route it through dynamic_runtime_lib
  • add an end-to-end //:lsan_test and run it with the Linux sanitizer tests
  • add a focused macOS CI job using LLVM 22.1.8

The Darwin version pin is deliberate. On current macOS, LLVM 19.1.7, 20.1.8, and 21.1.8 all run main and then deadlock during LSan's exit check. The leak-check thread calls dyld_shared_cache_iterate_text, which lazily loads dyld introspection code and allocates while LSan holds its allocator lock. LLVM compiler-rt #182943 switched this path to _dyld_get_dyld_header; that fix was backported to LLVM 22, and LLVM 22.1.8 exits normally.

The configured action graph now contains a SolibSymlink whose declared input is libclang_rt.lsan_osx_dynamic.dylib, so the runtime is provisioned rather than merely found incidentally in the local execroot.

Verification

On macOS arm64:

  • LLVM 19.1.7: times out after completing main
  • LLVM 20.1.8: times out after completing main
  • LLVM 21.1.8: times out after completing main
  • LLVM 22.1.8: //:lsan_test passes
  • //:sanitizer_combo_flags_test passes
  • actionlint and git diff --check pass

Upstream fix: llvm/llvm-project#182943

@helly25
helly25 enabled auto-merge (squash) August 16, 2026 14:52
@helly25
helly25 merged commit 9f7efa8 into bazel-contrib:master Aug 16, 2026
77 checks passed
@helly25
helly25 deleted the fix-826-lsan branch August 16, 2026 19:34
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.

lsan is not wired up: --features=lsan gets none of the sanitizer augmentation

1 participant