Skip to content

Add ThreadSanitizer CI jobs (Linux + macOS)#148

Draft
bghgary wants to merge 3 commits intoBabylonJS:mainfrom
bghgary:feature/thread-sanitizer
Draft

Add ThreadSanitizer CI jobs (Linux + macOS)#148
bghgary wants to merge 3 commits intoBabylonJS:mainfrom
bghgary:feature/thread-sanitizer

Conversation

@bghgary
Copy link
Copy Markdown
Contributor

@bghgary bghgary commented Apr 7, 2026

Add ThreadSanitizer (TSan) support for detecting data races at runtime.

Changes

  • CMakeLists.txt: New ENABLE_THREAD_SANITIZER option with -fsanitize=thread. Includes a mutual exclusion check with ENABLE_SANITIZERS since TSan and ASan cannot be combined.
  • linux.yml: New enableThreadSanitizer parameter, passed as ENABLE_THREAD_SANITIZER to CMake.
  • macos.yml: New enableThreadSanitizer parameter.
  • azure-pipelines.yml: New Ubuntu_ThreadSanitizer_clang and macOS_Xcode164_ThreadSanitizer CI jobs.

Platform Support

TSan is supported on Linux and macOS with Clang/GCC. MSVC does not support TSan and Clang targeting Windows does not have a TSan runtime library.

CI Impact

The TSan jobs run in parallel with other jobs and do not increase overall pipeline time.

Known Issues

TSan detects pre-existing data races in the codebase (e.g. in AppRuntime::Run). These are not introduced by this PR and should be addressed incrementally. The TSan jobs will fail until they are fixed.

bghgary and others added 2 commits April 7, 2026 16:16
Add ENABLE_THREAD_SANITIZER CMake option for detecting data races at
runtime. TSan cannot be combined with ASan, so it's a separate option
with a mutual exclusion check.

Adds an Ubuntu_ThreadSanitizer_clang CI job that runs the full test
suite under TSan.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bghgary bghgary marked this pull request as ready for review April 8, 2026 16:10
Copilot AI review requested due to automatic review settings April 8, 2026 16:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ThreadSanitizer (TSan) support to the build and CI to detect data races at runtime, integrating it alongside existing sanitizer infrastructure.

Changes:

  • Added ENABLE_THREAD_SANITIZER CMake option and wiring to apply -fsanitize=thread compile/link flags (with mutual exclusion vs ENABLE_SANITIZERS).
  • Extended the Linux CI template to accept an enableThreadSanitizer parameter and pass it through to CMake.
  • Added a new Azure Pipelines Linux/Clang TSan job.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
CMakeLists.txt Adds a dedicated CMake toggle for ThreadSanitizer and applies the required toolchain flags.
.gitignore Ignores the UnitTests dist/ output directory.
.github/jobs/linux.yml Adds a pipeline parameter/variable to enable TSan and passes it into the CMake configure step.
.github/azure-pipelines.yml Introduces a new Ubuntu/Clang ThreadSanitizer CI job using the Linux job template.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

MSVC does not support ThreadSanitizer. Added macOS CI job and
enableThreadSanitizer parameter to macos.yml.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bghgary bghgary changed the title Add ThreadSanitizer CI job Add ThreadSanitizer CI jobs (Linux + macOS) Apr 8, 2026
@bghgary bghgary marked this pull request as draft April 8, 2026 16:17
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