News for hackers. Stuff that matters.
Re:Swift Actors: A practical example, part 1 by mojuba on Tuesday May 11, 2021 @11:12AM (#27119037)
The author mentions "crash" multiple times - is it actually the case when unprotected ARC objects are concurrently accessed? Does it actually crash?
Re:Swift Actors: A practical example, part 1 by jmull on Tuesday May 11, 2021 @12:06PM (#27119831)
Looking 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.

Re:Swift Actors: A practical example, part 1 by wvdk on Tuesday May 11, 2021 @01:10PM (#27120622)
Yes, 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.