[SR-11055] swift_isUniquelyReferenced_nonNull_native crash #53447
Version 10.2.1 (10E1001) and proper Swift version
Additional Detail from JIRA
We recently published the application and found that the app crashes with such error
We have got three different stacks with such bug
They are near the same
The text was updated successfully, but these errors were encountered:
Looks like LegacyMechanic.append is accessing a bad pointer, either a junk value or a pointer to an object that has already been destroyed. swift_isUniquelyReferenced_nonNull_native just accesses the refcount field and returns the appropriate value. I'd suggest looking for thread safety problems or other memory management trouble. trololo (JIRA User), if you'd like to post a full crash log, I may be able to give a bit more info.
Thanks! This is interesting.
All three crashes are at the very first instruction of
I still think thread safety problems are the thing to look at. Something is overwriting an object pointer you're using, which could be due to your object being destroyed and another object allocated in its place. Two of the logs crashed while doing work inside
Comment by Vyacheslav (JIRA)
Ok. I've looked.
It seems you are right. But I don't actually understand why this code called twice at the same time.
LegacyInitializationMechanic contains dictionary inside.
As AppModelStorage, it seems you are right too. I'm removing and appending the object to the Set. The problem is that I currently don't understand why this method was called twice.
The most obvious solution is to wrap this code by serial operation queue. Am I right? Is it an expected behavior of a Collection?
Yes, it's expected that concurrently mutating a collection on one thread while accessing it (either reading or mutating it) on another thread could result in a crash or unpredictable behavior.
A serial queue would be a great way to fix this. Set it up so that all accesses to any given collection happen on one serial queue and everything will work.