9ef07d367e
### Description Adds ThreadSanitizer (TSAN) as a new CI job, adds TypeSanitizer (TypeSAN, Clang's `-fsanitize=type`) as a build option, and fixes a couple of pre-existing issues in the ASAN setup along the way. **CI** - New matrix entry: Ubuntu debug build on Python 3.14t (free-threaded) with `-DONNX_USE_TSAN=ON`, to catch data races — particularly relevant for free-threaded Python where the GIL no longer serializes access. - Added `TSAN_OPTIONS: suppressions=./tsan.supp` and a starter `tsan.supp` suppression list for known noisy/third-party findings (CPython internals, etc.). - **Fixed ASAN's `LD_PRELOAD` not actually taking effect**: the old step used `export LD_PRELOAD=...`, but `export` inside a GitHub Actions `run:` step only affects that step's own process — it never propagated to the later "Run Python/C++ tests" steps. Switched to `echo "LD_PRELOAD=..." >> $GITHUB_ENV`, which is the correct way to persist an env var across steps. Split into separate ASAN/TSAN steps, and also preload `libstdc++.so` alongside the sanitizer runtime (avoids known ODR-violation false positives between the sanitizer and libstdc++). - Tidied `ASAN_OPTIONS` (dropped defaults/no-ops like `symbolize=1`, `check_initialization_order=true` (superseded by `strict_init_order`)) and added `alloc_dealloc_mismatch=1:abort_on_error=1`. **Build (CMake)** - New `ONNX_USE_TSAN` and `ONNX_USE_TYPESAN` options in `CMakeLists.txt`, wired up in `cmake/Utils.cmake` alongside the existing ASAN/UBSAN linking. TypeSAN is added to the build system here but not yet turned on in CI. - `cmake/external/FindSanitizer.cmake`: added `Sanitizer::thread` and `Sanitizer::type` targets, migrated from the legacy per-language `CheckCSourceCompiles`/`CheckCXXSourceCompiles`/etc. modules to the unified `CheckSourceCompiles`/`CheckSourceRuns` (available since the project's CMake 3.26 minimum), and extended the self-verification step (compile+run a snippet that should trigger each sanitizer, to confirm it's actually catching bugs and not just linking) to memory and thread sanitizers as well, not just address/undefined. - Moved `find_package(Sanitizer REQUIRED)` earlier in `CMakeLists.txt` so the `Sanitizer::*` targets exist before `add_onnx_compile_options()` is called for `onnx_proto`/`onnx`/`onnx_cpp2py_export`. **REUSE** - Added `tsan.supp` to the `REUSE.toml` aggregate-copyright path list. --- ### Merge conflict resolution and fixes (andife, via Claude Code) Since "allow edits from maintainers" is enabled, I merged latest `main` and made two small fixes found in review: - **Merge conflict in `.github/workflows/main.yml`**: `main` independently flipped `detect_container_overflow` from `0` to `1` in `ASAN_OPTIONS` while this branch was in flight. Resolved by keeping `main`'s current tuning and layering this PR's own additions (`alloc_dealloc_mismatch`, `abort_on_error`) on top, rather than silently reverting `main`'s unrelated decision. - **`cmake/external/FindSanitizer.cmake`**: the self-verification loop now runs for `sanitizer_name = type` too, but no `_bug_type_code` variable was ever defined (only `_bug_address_code`/`_bug_undefined_code`/`_bug_thread_code`/`_bug_memory_code` exist). `check_source_runs()` against an undefined/empty variable fails to compile, which the surrounding logic treats as "no bug detected, sanitizer works" — so TypeSAN's self-test was silently a no-op. Added a minimal `_bug_type_code` snippet (write through an incompatible pointer type) matching the style of the existing ones. - **`.github/workflows/main.yml`**: restored `export LD_LIBRARY_PATH="./.setuptools-cmake-build/:$LD_LIBRARY_PATH"` before running `onnx_gtests`, which this PR had dropped without explanation. It's been present since this step was introduced and is documented in `CLAUDE.md` as required for Linux/macOS; removing it risks breaking C++ test execution for matrix entries that need to resolve a shared library from that build directory (e.g. External/dynamic-protobuf builds). Verified locally: `pixi run install` succeeds, 104/104 C++ gtests pass, lint clean. (Sanitizer-specific behavior — ASAN/TSAN/TypeSAN builds themselves — could not be exercised locally on this Windows/MSVC machine; that part still needs the actual CI run to confirm.) **AI tool disclosure**: the merge-conflict resolution and the two fixes above were made by @andife using [Claude Code](https://claude.com/claude-code) (Anthropic, Claude Sonnet 5) as a pair-programming assistant; every change was reviewed and explicitly approved before being pushed. This covers only that portion — @cyyever, feel free to add a note on what (if anything) was used for the original PR content. ### Motivation and Context This PR adds TSAN to the CI matrix and adds TypeSAN support to the build system, to catch data races and type-confusion bugs that ASAN/UBSAN don't cover — particularly useful for the free-threaded Python (3.14t) build where the GIL no longer serializes access to shared state. --------- Signed-off-by: Yuanyuan Chen <cyyever@outlook.com> Signed-off-by: cyy <cyyever@outlook.com> Signed-off-by: Andreas Fehlner <fehlner@arcor.de> Co-authored-by: Andreas Fehlner <fehlner@arcor.de> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
5 lines
70 B
Plaintext
5 lines
70 B
Plaintext
race:v8::
|
|
race:object_stack
|
|
race:mi_segment_page_clear
|
|
race:libpython
|