Skip to content

ASan TSan#196

Draft
tameware wants to merge 10 commits into
dds-bridge:developfrom
tameware:asan-tsan
Draft

ASan TSan#196
tameware wants to merge 10 commits into
dds-bridge:developfrom
tameware:asan-tsan

Conversation

@tameware

Copy link
Copy Markdown
Collaborator

Fix ASan (AddressSanitizer) and TSan (ThreadSanitizer) builds on macOS. These are used for testing.

tameware and others added 5 commits June 18, 2026 14:25
Co-authored-by: Cursor <cursoragent@cursor.com>
docs/BUILD_SYSTEM.md — new section “AddressSanitizer and ThreadSanitizer (macOS)” covering:

The three-way clang major coupling (MODULE.bazel, Xcode, .bazelrc TSAN rpath)
Why ASAN uses the full Xcode toolchain vs TSAN using LLVM compile + Xcode runtime
Steps when upgrading LLVM or Xcode
Smoke-test commands
Also corrected the outdated LLVM version note (darwin was listed as 20.1.8; it’s 21.1.8).

.bazelrc — short pointers to BUILD_SYSTEM.md; TSAN rpath comment notes the hardcoded clang/21 must stay in sync.

MODULE.bazel — comment on llvm_versions to update the TSAN rpath and verify Xcode when bumping LLVM.
@zzcgumn

zzcgumn commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

This looks useful. Xcode's llvm version was far too old when I first tried to add the ASAN and TSAN options.

tameware added 3 commits June 18, 2026 15:26
…arking global arrays as static. Commented out unused SORT_SOLVE_STRENGTH and SORT_SOLVE_STRENGTH_CUTOFF
@tameware tameware self-assigned this Jun 18, 2026
tameware added 2 commits June 18, 2026 16:31
The BUILD change ensures a stats test links only system_util_stats, not system + system_util_stats. One system variant → one ThreadMgr → one set of mutexes. That matches the intent: a process-wide thread manager.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes macOS sanitizer (ASan/TSan) builds by switching to Bazel --config-based sanitizer wiring, selecting an Xcode toolchain for ASan, and documenting/version-coupling the macOS runtime requirements.

Changes:

  • Add apple_support (Bzlmod) and wire an Apple toolchain repo for macOS ASan builds; update .bazelrc ASan/TSan configs accordingly.
  • Remove legacy --define=asan=true plumbing and update docs/instructions to use --config=asan / --config=tsan.
  • Add Linux/macOS sanitizer CI coverage and adjust internal build targets to avoid linking mismatched system variants.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
MODULE.bazel.lock Updates module lock to reflect new dependency graph.
MODULE.bazel Adds apple_support and configures Apple toolchain repos; documents clang-major coupling.
.bazelrc Reworks ASan/TSan configs for macOS (Xcode toolchain for ASan; Xcode runtime rpath for TSan).
BUILD.bazel Removes legacy //:asan config_setting.
CPPVARIABLES.bzl Removes --define=asan=true-based sanitizer flags from global opts/linkopts.
docs/BUILD_SYSTEM.md Documents macOS ASan/TSan behavior, coupling points, and CI commands.
.github/copilot-instructions.md Updates guidance to use --config=asan.
.github/workflows/ci_linux.yml Adds ASan/TSan jobs and timeouts; uploads logs.
.github/workflows/ci_macos.yml Adds sanitizer job and timeouts; uploads logs.
.github/workflows/ci_windows.yml Adds job timeout.
.github/workflows/ci_wasm.yml Adds job timeout.
library/src/system/BUILD.bazel Clarifies that multiple system variants share sources and shouldn’t be co-linked.
library/src/solver_context/BUILD.bazel Switches log/stats variants to depend on corresponding system variants.
library/src/system/thread_mgr.cpp Moves global mutexes into an anonymous namespace for internal linkage.
library/src/system/scheduler.cpp Gives internal linkage to scheduling constant tables (avoids cross-TU symbol collisions).
library/src/moves/moves.cpp Zero-initializes moveList entries in constructor to avoid uninitialized state.
library/src/heuristic_sorting/heuristic_sorting.cpp Minor conditional adjustment for g boundary check.

@tameware

Copy link
Copy Markdown
Collaborator Author

This PR includes several sets of commits that could be submitted separately:

  1. Fix the broken ASan and TSan configurations for macOS. They can work now that Xcode's llvm is more up to date.
  2. Add ASan and TSan builds to CI.
  3. Set all CI timeouts to 20 minutes. Most had the default of six hours.
  4. Fix the unsafe code that ASan identified.

It was expedient to do this together. Let me know if you'd rather see separate PRs for each.

@tameware tameware requested a review from zzcgumn June 19, 2026 02:35
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.

3 participants