Daily iOS
Testing

Testing concurrent code

How do you reproduce or detect a data race in concurrent code that uses actors and Tasks?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Swift 6 strict concurrency blocks most Sendable violations at compile time, and what's left shows up in a stress test that calls the same code hundreds of times from a TaskGroup with Thread Sanitizer on, which reports the race with a stack. Read actor state with await to verify it.

Share a question