LLVM TSAN / ASAN
For multithreaded and low-level unsafe interfacing server code, the ability to use LLVM’s ThreadSanitizer and AddressSanitizer can help troubleshoot invalid thread usage and invalid usage/access of memory.
There is a blog post outlining the usage of TSAN.
The short story is to use the swiftc command line options -sanitize=address and -sanitize=thread to each respective tool.
Also for Swift Package Manager projects you can use --sanitize at the command line, e.g.:
swift build --sanitize=address
or
swift build --sanitize=thread
and it can be used for the tests too:
swift test --sanitize=address
or
swift test --sanitize=thread
The Swift Programming Language, Copyright © 2014-2025 Apple Inc.
Swift and the Swift logo are trademarks of Apple Inc.
Documentation for Swift 6.0.3
https://www.swift.org/documentation/server/guides/llvm-sanitizers.html