What can we know for certain based on the fact that the call to swift_retain was the final step on the crashing thread?
It’s hard to know anything for certain, but it’s most likely that you have some sort of memory management problem that’s corrupted stuff to the point that swift_retain ends up being called with a bogus parameter. In cases like this my general advice is that you deploy the standard memory debugging tools to see if you can make the problem more reproducible, and hence fixable.
However, that’s just a guess. I might be able to say more if you posted the full crash report. I have some advice on that front here; just skip the stuff that’s DevForums specific.
Thank you for so many leads - I'm happy to know that you share your expertise here on the Swift forum too!
I've only tried to use the memory debugging tools a few times in my life and thus far I've had difficulty getting comprehensible answers about my problems, so before I dive into that I'd like to ask, would the type of memory management problem that you're talking about be possible in a program written purely in the higher levels of Swift? (i.e., no C interop, none of the Unsafe Swift types)