Skip to content
Commitwise
Menu

Thread Sanitizer

Also called: TSan

A runtime tool that reports data races, two threads accessing the same memory at once, during a debug or test run.

Definition

TSan instruments memory accesses and reports conflicting ones even when the run doesn't crash, with the stack traces of both threads. It slows the app down, so it's used in tests and debugging, not in release builds. It finds races in code the Swift 6 compiler can't check, such as unchecked Sendable types and C code.

In practice

A test that downloads 50 images at once makes TSan report concurrent writes to a cache dictionary.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.