Skip to content

Add ThreadSanitizer (TSan) tests to CI #29

@edge90

Description

@edge90

Summary

Add ThreadSanitizer (TSan) to the CI pipeline to catch data races and threading bugs automatically.

Background

During recent test fixes, TSan helped identify data races in TrackedString/TrackingCounter that weren't caught by regular tests or ASan. TSan is valuable for a threading-heavy library like ev_loop.

Proposed Implementation

Add a TSan configuration to the matrix include section in ci.yaml:

matrix:
  # ... existing configuration ...
  
  include:
    # ... existing includes ...
    
    # ThreadSanitizer build (Clang only, mutually exclusive with ASan/UBSan)
    - os: ubuntu-latest
      compiler: llvm-19.1.1
      generator: "Ninja Multi-Config"
      build_type: Debug
      packaging_maintainer_mode: ON
      enable_tsan: ON

Then conditionally pass the TSan flag in the CMake configure step:

-Dev_loop_ENABLE_SANITIZER_THREAD=${{ matrix.enable_tsan || 'OFF' }}

Notes

  • TSan cannot run alongside ASan/UBSan (mutually exclusive)
  • Use PACKAGING_MAINTAINER_MODE=ON to disable other sanitizers by default
  • Single configuration (Clang + Debug) is sufficient for TSan coverage
  • Clang has better TSan support than GCC

Metadata

Metadata

Assignees

No one assigned

    Labels

    github_actionsPull requests that update GitHub Actions codegood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions