[swift-users] _swift_abortRetainUnowned when capturing @objc class as unowned

Michael Gottesman mgottesman at apple.com
Wed Dec 23 12:46:35 CST 2015


> On Dec 23, 2015, at 6:31 AM, Tadeas Kriz via swift-users <swift-users at swift.org> wrote:
> 
> Hey,
> 
> I am experiencing this strange crashing when capturing an instance of a @objc class (written in swift, but annotated with @objc and subclass of NSObject). It happens when the closure is being assigned and not when called, so the problem is not that the captured value would get deallocated and then the closure called. It happens randomly, sometimes it crashes sooner, sometimes later. I was experiencing this bug in earlier versions of Swift (I think it was Swift 1.2), but now I'm using 2.1 and getting this crash too.
> 
> It works well when I change `[unowned x]` to `[weak x]` and then access it by force unwrapping `x!.doSomething()` which leads me to believe it is a bug in Swift, rather than in my code. However before opening a ticket at bugs.swift.org <http://bugs.swift.org/>, I wanted to get more eyes on this to make sure I'm not missing anything.

Do you have a small test case? Can you file a bug?

Michael

> 
> It was also mentioned here:
> http://www.codeproject.com/Articles/791304/Resolving-strong-references-between-Swift-and-Obje <http://www.codeproject.com/Articles/791304/Resolving-strong-references-between-Swift-and-Obje>
> here:
> https://www.reddit.com/r/swift/comments/3vhwmj/unowned_bug_in_closure_causes_attempted_to_retain/ <https://www.reddit.com/r/swift/comments/3vhwmj/unowned_bug_in_closure_causes_attempted_to_retain/>
> and here:
> https://forums.developer.apple.com/thread/9873 <https://forums.developer.apple.com/thread/9873>
>  _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151223/6f71d1f9/attachment.html>


More information about the swift-users mailing list