Concurrency Testing vs. Thread Sanitizer

Now that cancellation is mostly handled, there's one last concurrency issue remaining for Alamofire: testing with the thread sanitizer enabled. On our feature/async-handlers branch, running a single test in ConcurrencyTests works just fine with the sanitizer enabled. Trying to run multiple tests with the sanitizer enabled leads to many sanitizer issues for each test. For a run of the 10 test methods in DataConcurrencyTests I get 46 sanitizer warnings. The entire rest of Alamofire's test suite produces zero. (We did recently fix some safety issues with our dynamicMemeberLookup use, but those didn't appear in the sanitizer.)

There are so many I had to turn it into a gist: Alamofire Test Thread Sanitizer Issues · GitHub

Some seem to be issues in the concurrency runtime, some are in Alamofire itself, especially between property getters and initializers, which doesn't make much sense. Even running just two tests results in three warnings.

So, do I have an actual safety issue, or are there issues with the thread sanitizer and async tests (or concurrency APIs in general)? Anyone else seeing this? Should this be a Swift or Apple bug report?

(cc @Douglas_Gregor and @John_McCall, as these seem to be the same issues seen in our WWDC lab)

The most likely thing is that these are all false positives introduced by a lack of annotations making TSan aware of the memory-ordering relationship between two events. Probably it's just one or two such cases that just happen to fire all over the place.

Anything I can do in my tests to leave the sanitizer enabled for everything else but ignore the issues for these tests?

I'll report the bug as false positives.

I've reported [SR-15444] Many Thread Sanitizer False Positives In Async Tests - Swift in the meantime.

3 Likes
Terms of Service

Privacy Policy

Cookie Policy