I tried the concurrency project in XCode 14.3.1. TSAN doesnโt display a purple warning but shows the following error message in the XCode console instead. Concurrency(83742,0x101184240) malloc: nano zone abandoned due to inability to reserve vm space.
Of course, if I remove the thread sanitizer option, the message will disappear.
hi Suppasit! The Concurrency project doesnโt trigger TSan in Xcode 14. NameChanger does โ try that? Or, Iโve rewritten that project for the course update Iโm currently working on โ I sleep a random time in both for loops:
func raceYou() {
var counter = 0
let queue = DispatchQueue(label: "notMain")
queue.async {
for _ in 1 ... 10 {
Thread.sleep(forTimeInterval: Double.random(in: 0.1..<0.5))
counter += 1
}
print(">>> notMain Queue counter = \(counter)")
}
DispatchQueue.main.async {
for _ in 1 ... 10 {
Thread.sleep(forTimeInterval: Double.random(in: 0.1..<0.5))
counter += 1
}
print(">>> Main Queue counter = \(counter)")
}
}
Thank you for your comment. I have tried the code you provided, and TSAN is reporting an error on the main queue. Could this possibly mean that the main queue is causing a race condition by accessing the same variable as the custom queue?