Repository navigation
Description
Proposal
Context
The repository CI currently includes an ASan/UBSan configuration, but there is no ThreadSanitizer profile. The SDK now contains substantial concurrent code around shared HTTP streaming reactors, callback dispatch, stream cancellation, shutdown, subscriptions, and store coordination.
These paths are covered by deterministic tests, but ordinary debug builds and ASan/UBSan do not detect data races.
Goal
Add a focused ThreadSanitizer validation profile that detects SDK-owned data races without turning every pull request into an excessively expensive full-suite TSan run.
Scope
1. Add a TSan build profile
Use Clang on Linux with flags equivalent to:
-fsanitize=thread -fno-omit-frame-pointer
Configure the SDK with testing enabled and build the concurrency-sensitive test targets required by the selected profile.
2. Run a focused deterministic test set
Include tests that exercise SDK-owned concurrency, especially where supported by TSan:
- stream handle lifecycle and cancellation;
- HTTP client reactor lifecycle;
- JSON-RPC / HTTP+JSON streaming cancellation;
- subscription publication/cancellation;
- in-memory store concurrency;
- dispatcher/executor shutdown races where applicable.
Do not add sleep-heavy stress tests merely to make TSan useful. Prefer existing deterministic synchronization helpers and targeted regression tests.
3. Handle third-party limitations explicitly
If gRPC, libcurl, libc, or another third-party component produces known external TSan noise:
- first determine whether the report originates in SDK-owned code;
- keep suppressions minimal and documented;
- do not suppress broad symbol namespaces simply to make the job green;
- prefer selecting a focused test set that exercises SDK synchronization while avoiding unsupported third-party paths.
4. Choose an appropriate cadence
If the runtime cost is acceptable, run the profile on relevant pull requests. Otherwise run it on main, scheduled CI, and manual dispatch while keeping a small PR smoke subset.
Non-goals
- Replacing ASan/UBSan.
- Adding new runtime features.
- Using TSan failures as a reason to weaken concurrency assertions.
- Introducing
NOLINTor sanitizer suppressions for SDK-owned races. - Running PostgreSQL integration under TSan unless it is stable and useful.
Acceptance criteria
- CI has a reproducible Clang ThreadSanitizer build profile.
- The profile executes a documented set of concurrency-sensitive SDK tests.
- The selected tests complete without SDK-owned TSan findings.
- Any sanitizer suppressions are narrow, documented, and limited to verified third-party behavior.
- The job does not rely on arbitrary retry loops to pass.
- New concurrency regression tests can be added to the profile easily.
- Existing ASan/UBSan validation remains in place.
- No public SDK API changes are introduced.
Motivation
v0.5.0 substantially improved streaming concurrency and shared-reactor behavior. Adding race detection in v0.5.1 is a maintenance-oriented way to harden that work before expanding the asynchronous API surface in v0.6.0.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity