4 ms·
The author mentions "crash" multiple times - is it actually the case when unprotected ARC objects are concurrently accessed? Does it actually crash?
by mojuba 5y ago
The author mentions "crash" multiple times - is it actually the case when unprotected ARC objects are concurrently accessed? Does it actually crash?
- jmull 5y agoLooking at the Person class in the article, which has just a “name” property with String type… I think if you mutate that string from multiple threads — like by appending to it — you would get crashes pretty easily. I’m really not sure if you would see crashes if you simply access and assign to the name property (rather than mutating the value it is pointing to). I have not seen guarantees on this. Maybe I missed it, but if not, even if it appears to work today, it may not tomorrow.
- wvdk 5y agoYes, it does crash if two threads write to a property at the same time. The worst thing about this kind of bug is the inconsistency - often being discovered first by real users. There are also a plethora of shared state bugs that should be reduced with clearer concurrency semantics. All-around big step forward towards Swift's goal of being a "safe" language.