feat(#459): Add ASan + TSan CI gates for mutex and buffer safety#498
Merged
feat(#459): Add ASan + TSan CI gates for mutex and buffer safety#498
Conversation
Configure separate TSan build with -Db_sanitize=thread for PR merge gate. Validates mutex safety in I/O adapter registry and workqueue. Linux GCC and Clang only (TSan/ASan mutually exclusive).
Add non-blocking TSan job (continue-on-error: true) for Linux GCC and Clang. Monitors thread safety on main branch pushes without blocking merges. TSan and ASan are mutually exclusive; separate job avoids flag conflicts.
Three scenarios under TSan: concurrent find (8 threads x 2000 iters), concurrent register/unregister (8 threads each owning a unique scheme), and mixed readers+writers (4 find + 4 reg/unreg threads simultaneously). Exercises mutex safety in the 32-slot registry. POSIX only; skipped on Windows.
Ten boundary/error scenarios: NULL adapter, NULL scheme, NULL find/unregister, ABI mismatch, max-length scheme boundary (63 chars), overlong scheme safe truncation, registry-full overflow, unregister nonexistent, error-string cleared after success. ASan catches out-of-bounds writes on internal scheme copy; UBSan catches NULL deref on error paths.
…o_adapter.h Add inline documentation for the Registration API covering: - Adapter pointer lifetime (must outlive unregister/process exit) - Scheme string is copied internally at registration (safe to reuse after) - Thread safety guarantee (mutex-guarded; validated by TSan CI gate) - Error reporting contract (thread-local buffer, cleared on success) - Return value summary for all three public functions
Replace single-phase flag (0=uninit, 1=ready) with two-phase protocol: 0 -> 1: winning thread claims init via InterlockedCompareExchange 1 -> 2: winning thread sets done only after mutex_init() returns Competing threads spin on SwitchToThread() until phase 2 is visible. Previously, a second thread could see flag=1 and call mutex_lock() on a CRITICAL_SECTION that had not yet been initialised by the winner.
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
Implements Issue #459: ASan + TSan CI gates for comprehensive mutex and buffer safety validation.
Addresses Issue #446 (user-defined I/O adapters) by adding:
Test Plan
Commits
afbf114- feat([NEW] ASan + TSan CI gates as discrete jobs #459): Add TSan CI gate to ci-pr.yml (blocking)15099af- feat([NEW] ASan + TSan CI gates as discrete jobs #459): Add TSan monitoring job to ci-main.yml (non-blocking)f109575- test([NEW] ASan + TSan CI gates as discrete jobs #459): Add concurrent I/O adapter registry stress testcbd83d6- test([NEW] ASan + TSan CI gates as discrete jobs #459): Add mock-adapter error-path tests for ASane3762ee- docs([NEW] ASan + TSan CI gates as discrete jobs #459): Document adapter lifetime contract and thread safety8a2b304- fix([NEW] ASan + TSan CI gates as discrete jobs #459): Fix Windows ensure_builtins() CRITICAL_SECTION init raceVerification