Skip to content

Add UndefinedBehaviorSanitizer build/test option - #288

Open
tameware wants to merge 1 commit into
dds-bridge:developfrom
tameware:ubsan
Open

Add UndefinedBehaviorSanitizer build/test option#288
tameware wants to merge 1 commit into
dds-bridge:developfrom
tameware:ubsan

Conversation

@tameware

@tameware tameware commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add standalone --config=ubsan (not combined with ASan) with macOS Xcode compiler-rt rpath, matching the TSan pattern
  • Wire UBSan into Linux CI (ubsan job on //library/tests/...) and macOS sanitizers job
  • Fix UBSan-found undefined behavior: rank_[-1] in lookup-table init, first[-4] on empty deals in solve_board, and fullseq_[-1] in get_top_number for empty suits

Test plan

  • bazelisk test --config=ubsan //library/tests/... (41/41 pass locally on macOS)
  • Linux CI ubsan job green
  • macOS CI sanitizers job includes UBSan step and stays green
  • Spot-check docs: docs/BUILD_SYSTEM.md UBSan section matches .bazelrc

Made with Cursor

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>
@tameware tameware self-assigned this Aug 4, 2026
@tameware
tameware requested a lite review from Copilot August 4, 2026 21:05

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

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=ubsan in .bazelrc, document it, and expose it in Copilot instructions.
  • Run UBSan in GitHub Actions (Linux: new ubsan job; macOS: add UBSan step in sanitizers job).
  • 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.

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
tameware requested review from tzimnoch and zzcgumn and removed request for tzimnoch August 4, 2026 21:28
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.

2 participants