Add UndefinedBehaviorSanitizer build/test option - #288
Open
tameware wants to merge 1 commit into
Open
Conversation
Introduce --config=ubsan (with macOS Xcode runtime rpath) and wire it into Linux/macOS CI alongside ASan/TSan. Repair out-of-bounds accesses in lookup table init, empty-deal solve_board setup, and get_top_number on empty suits. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a standalone UndefinedBehaviorSanitizer (UBSan) Bazel config and wires it into CI, then fixes several UBSan-reported undefined behaviors in core lookup-table initialization, solver initialization, and heuristic sorting edge cases.
Changes:
- Add
--config=ubsanin.bazelrc, document it, and expose it in Copilot instructions. - Run UBSan in GitHub Actions (Linux: new
ubsanjob; macOS: add UBSan step insanitizersjob). - Fix undefined behavior in:
- lookup-table group gap computation (
rank_[-1]case), - solver look-ahead
first[]indexing on invalid/degenerate deals, get_top_number()for empty suits (fullseq_[-1]case), plus targeted tests.
- lookup-table group gap computation (
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| library/tests/utility/lookup_tables_test.cpp | Adds regression coverage for empty/single-card suit group initialization invariants. |
| library/tests/heuristic_sorting/targeted_unit_tests.cpp | Tightens edge-case expectation for empty-suit get_top_number() behavior. |
| library/src/solver_if.cpp | Avoids invalid first[] indexing before last-trick / validation handling. |
| library/src/lookup_tables/lookup_tables.cpp | Prevents rank_[g-1] access when opening the first group from an empty suit. |
| library/src/heuristic_sorting/heuristic_sorting.cpp | Guards empty-suit get_top_number() to avoid fullseq_[-1] access. |
| docs/BUILD_SYSTEM.md | Documents UBSan usage and macOS runtime coupling (matching TSAN pattern). |
| .github/workflows/ci_macos.yml | Adds UBSan fetch + test step to the macOS sanitizers workflow. |
| .github/workflows/ci_linux.yml | Adds a dedicated Linux UBSan CI job running //library/tests/.... |
| .github/copilot-instructions.md | Adds the UBSan Bazel config command to the contributor guidance. |
| .bazelrc | Introduces --config=ubsan and macOS rpath wiring for UBSan runtime loading. |
tameware
requested review from
tzimnoch and
zzcgumn
and removed request for
tzimnoch
August 4, 2026 21:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--config=ubsan(not combined with ASan) with macOS Xcodecompiler-rtrpath, matching the TSan patternubsanjob on//library/tests/...) and macOSsanitizersjobrank_[-1]in lookup-table init,first[-4]on empty deals insolve_board, andfullseq_[-1]inget_top_numberfor empty suitsTest plan
bazelisk test --config=ubsan //library/tests/...(41/41 pass locally on macOS)ubsanjob greensanitizersjob includes UBSan step and stays greendocs/BUILD_SYSTEM.mdUBSan section matches.bazelrcMade with Cursor