Using the thread sanitizer with swift test


(Martin Angers) #1

Hello,

This is my first message to the swift mailing lists, so I'd like to start
with a big thank you to the Swift core team and collaborators for all the
hard work.

My question is related to the thread sanitizer tool. Having worked mostly
with Go in recent years, I've become spoiled by the tooling and was really
happy to see that swift also had a data race detector. However, where in Go
I can write `go test -race` to run tests with the detector enabled, I tried
`swift test -Xswiftc -sanitize=thread` but ended up with the following
error:

"==46839==ERROR: Interceptors are not working. This may be because
ThreadSanitizer is loaded too late (e.g. via dlopen)."

`swift build -Xswiftc -sanitize=thread` seems to work (i.e. it compiles
without error) but since I want to test a library, that's not helpful in my
case.

Is that something that should be currently supported - in which case I'm
missing something - or if not, is it something that is likely to be
supported in the future? And then the next best thing at the moment would
be to write an executable that exercises my library and build+run it with
the thread sanitizer?

Thanks,
Martin Angers