I have found a few different topics on Thread Sanitizer (TSAN) and structured concurrency.
One even seems to indicate that TSAN should work better with Xcode 14.
I am getting what I believe is a false positive from TSAN in Xcode Version 14.2 (14C18).
Specifically this code to create an Author
await context.perform {
let known = Author(context: context)
known.fullName = "000000"
}
Is providing this error when run in our test suite.
CoreData: annotation: Core Data multi-threading assertions enabled.
==================
WARNING: ThreadSanitizer: data race (pid=4127)
Read of size 8 at 0x7b6400030500 by thread T3:
#0 (2) await resume partial function for FetchRequestPublisherTests.testNoEmitUntilInitialFetchComplete() FetchRequestPublisherTests.swift:46 (AnnotationsTests:x86_64+0x17df1)
#1 swift::runJobInEstablishedExecutorContext(swift::Job*) <null>:2 (libswift_Concurrency.dylib:x86_64+0x2a425)
Previous write of size 8 at 0x7b6400030500 by thread T2:
#0 (1) suspend resume partial function for FetchRequestPublisherTests.testNoEmitUntilInitialFetchComplete() FetchRequestPublisherTests.swift:46 (AnnotationsTests:x86_64+0x17c18)
#1 swift::runJobInEstablishedExecutorContext(swift::Job*) <null>:2 (libswift_Concurrency.dylib:x86_64+0x2a425)
Location is heap block of size 1032 at 0x7b6400030200 allocated by thread T2:
#0 malloc <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x5545c)
#1 swift::StackAllocator<1000ul, &(swift::TaskAllocatorSlabMetadata)>::getSlabForAllocation(unsigned long) <null>:2 (libswift_Concurrency.dylib:x86_64+0x2f12a)
#2 swift::runJobInEstablishedExecutorContext(swift::Job*) <null>:2 (libswift_Concurrency.dylib:x86_64+0x2a425)
Thread T3 (tid=30475, running) is a GCD worker thread
Thread T2 (tid=30474, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race FetchRequestPublisherTests.swift:46 in (2) await resume partial function for FetchRequestPublisherTests.testNoEmitUntilInitialFetchComplete()
Is this just expected that TSAN cannot handle this (yet)?