Skip to content

Fix macOS sanitizer setup for example runner - #3645

Merged
zackees merged 1 commit into
masterfrom
fix/3642-macos-example-asan
Jul 15, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/3642-macos-example-asan

Conversation

@zackees

@zackees zackees commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Summary

  • centralize debug sanitizer environment setup in one shared helper
  • make both the unit-test runner and example runner consume that helper
  • on Darwin, replace unsupported detect_leaks=1 with detect_leaks=0 while retaining ASan and UBSan
  • add regression coverage that prevents the two runners from drifting again

Root cause

PR #3644 fixed the macOS sanitizer runtime and options for the unit-test path. The example runner still had a copied sanitizer setup that reintroduced detect_leaks=1, causing every debug example to abort before entering main on macOS 26.

Validation

  • uv run pytest ci/tests/test_meson_native_toolchain.py -q: 12 passed, 4 subtests passed
  • uv run pytest ci/tests -q --ignore=ci/tests/test_fbuild_qemu.py: 521 passed, 39 skipped, 9 subtests passed
  • bash lint: passed
  • focused Python review: clean after removing one stale import

Acceptance

Refs #3642. Keep the issue open through merge; close it only after both macOS unit tests and macOS example tests are green on current master.

Summary by CodeRabbit

  • Bug Fixes

    • Improved debug test runs by configuring AddressSanitizer and LeakSanitizer settings consistently across native and example test runners.
    • Fixed macOS debug runs by disabling unsupported leak detection while preserving other sanitizer checks.
    • Improved resolution of specifically requested Meson tests, including fallback and fuzzy name matching.
  • Refactor

    • Consolidated sanitizer environment setup to provide more consistent behavior across test workflows.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change centralizes sanitizer environment setup in a new helper, updates both Meson runners to use it, adds regression coverage, and introduces candidate resolution for requested Meson test names.

Changes

Sanitizer setup centralization

Layer / File(s) Summary
Shared sanitizer environment helper
ci/meson/sanitizer_env.py
Adds shared ASan/LSan environment setup, macOS leak-detection handling, suppression-file support, and verbose symbolizer logging.
Runner sanitizer wiring
ci/meson/runner.py, ci/util/meson_example_runner.py, ci/tests/test_meson_native_toolchain.py
Updates native and example runners to call the shared helper and validates the new wiring and platform-specific behavior.

Meson test name resolution

Layer / File(s) Summary
Test name candidate resolution
ci/meson/runner.py
Adds primary, fallback, and fuzzy executable candidates for requested test names.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clear and related to the main sanitizer fix, though it focuses on the example runner rather than the shared helper change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/3642-macos-example-asan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
ci/meson/runner.py (2)

280-301: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Accept an optional list of arguments for testing flexibility.

As per coding guidelines, functions that parse arguments (like this CLI entry point) must accept an optional list[str] parameter so that they can be tested programmatically without mocking sys.argv.

♻️ Proposed refactor
-def main() -> None:
+def main(sys_args: list[str] | None = None) -> None:
     """CLI entry point for Meson build system runner."""
     parser = argparse.ArgumentParser(
         description="Meson build system runner for FastLED"
     )
     parser.add_argument("--test", help="Specific test to build and run")
     parser.add_argument("--clean", action="store_true", help="Clean build directory")
     parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output")
     parser.add_argument(
         "--debug", action="store_true", help="Enable debug mode with full symbols"
     )
     parser.add_argument(
         "--build-mode",
         choices=["quick", "debug", "release", "profile"],
         help="Build mode (quick, debug, release, profile)",
     )
     parser.add_argument(
         "--check", action="store_true", help="Enable IWYU static analysis"
     )
     parser.add_argument("--build-dir", default=".build/meson", help="Build directory")
 
-    args = parser.parse_args()
+    args = parser.parse_args(sys_args)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/meson/runner.py` around lines 280 - 301, Update the main CLI entry point
to accept an optional list[str] argument and pass it to
argparse.ArgumentParser.parse_args, while preserving default command-line
behavior when no list is provided.

Source: Coding guidelines


46-48: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use a dataclass struct instead of a tuple for multiple return values.

As per coding guidelines, functions returning multiple values must use @dataclass structs instead of tuples or dicts. Define a TestNameCandidates dataclass with @typechecked to resolve this across the function contract and call sites.

  • ci/meson/runner.py#L46-L48: Define the dataclass and update the return type signature of _resolve_test_name_candidates.
  • ci/meson/runner.py#L73-L73: Return an instance of the dataclass instead of a tuple.
  • ci/meson/runner.py#L187-L190: Update the call site to access the dataclass properties instead of unpacking a tuple.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/meson/runner.py` around lines 46 - 48, Define a `@typechecked`
TestNameCandidates dataclass in ci/meson/runner.py and change
_resolve_test_name_candidates to return it instead of a tuple; update
ci/meson/runner.py lines 73 and 187-190 to construct the dataclass and access
its named properties rather than unpacking the tuple.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@ci/meson/runner.py`:
- Around line 280-301: Update the main CLI entry point to accept an optional
list[str] argument and pass it to argparse.ArgumentParser.parse_args, while
preserving default command-line behavior when no list is provided.
- Around line 46-48: Define a `@typechecked` TestNameCandidates dataclass in
ci/meson/runner.py and change _resolve_test_name_candidates to return it instead
of a tuple; update ci/meson/runner.py lines 73 and 187-190 to construct the
dataclass and access its named properties rather than unpacking the tuple.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cf4fb887-da96-4b22-a40a-a162979d9640

📥 Commits

Reviewing files that changed from the base of the PR and between efd5de2 and 3fc0c66.

📒 Files selected for processing (4)
  • ci/meson/runner.py
  • ci/meson/sanitizer_env.py
  • ci/tests/test_meson_native_toolchain.py
  • ci/util/meson_example_runner.py

@zackees
zackees merged commit 862508e into master Jul 15, 2026
13 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jul 15, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 15, 2026
@zackees
zackees deleted the fix/3642-macos-example-asan branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant