swift icon indicating copy to clipboard operation
swift copied to clipboard

[SR-15291] Concurrency: Crash when invoking async @objc function

Open mickeyl opened this issue 4 years ago • 8 comments

Previous ID SR-15291
Radar None
Original Reporter @mickeyl
Type Bug

Environment

macOS Big Sur, Xcode 13, iOS 15

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 6dd0e24a6fb0f8662c8211501fdd40f3

Issue Description:

Adding the `async` modifier to an `@objc` function crashes when invoking that function via a Notification observer.

The backtrace is here:

(lldb) bt
* thread #​6, queue = 'com.apple.root.default-qos', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #​0: 0x000000010c647928 libobjc.A.dylib`objc_release + 8
    frame #​1: 0x000000010d3aba95 Foundation`-[NSConcreteNotification dealloc] + 49
    frame #​2: 0x000000010c6479f7 libobjc.A.dylib`objc_object::sidetable_release(bool, bool) + 177
  * frame #​3: 0x000000010c1d6b8a SR555`closure #​1 in ViewController.viewDidLoad(self=0x00007fda09807c40) at ViewController.swift:20:40
    frame #&#8203;4: 0x000000010c1d6c48 SR555`thunk for @escaping @callee_guaranteed () -> () at <compiler-generated>:0
    frame #&#8203;5: 0x000000010d9d3c0c libdispatch.dylib`_dispatch_client_callout + 8
    frame #&#8203;6: 0x000000010d9d6595 libdispatch.dylib`_dispatch_continuation_pop + 594
    frame #&#8203;7: 0x000000010d9eaea0 libdispatch.dylib`_dispatch_source_invoke + 2166
    frame #&#8203;8: 0x000000010d9d5ecd libdispatch.dylib`_dispatch_queue_override_invoke + 584
    frame #&#8203;9: 0x000000010d9e5b44 libdispatch.dylib`_dispatch_root_queue_drain + 403
    frame #&#8203;10: 0x000000010d9e65ec libdispatch.dylib`_dispatch_worker_thread2 + 196
    frame #&#8203;11: 0x00007fff6bfeb417 libsystem_pthread.dylib`_pthread_wqthread + 244
    frame #&#8203;12: 0x00007fff6bfea42f libsystem_pthread.dylib`start_wqthread + 15
(lldb) 

An example project to clone is here: https://github.com/mickeyl/swift-bugs – directory SR15291

mickeyl avatar Oct 07 '21 13:10 mickeyl

Same in 5.5.2-dev as per Xcode 13.2.0 beta 2.

mickeyl avatar Nov 17 '21 10:11 mickeyl

Likewise in 5.5.2-dev as per Xcode 13.2.0 RC.

mickeyl avatar Dec 08 '21 12:12 mickeyl

Still a problem in Xcode 13.3.0 RC.

mickeyl avatar Mar 09 '22 21:03 mickeyl

Still a problem in 5.6.1 as per Xcode 13.4 RC.

mickeyl avatar May 13 '22 07:05 mickeyl

Still a problem in 5.7 as per Xcode 14.0 Beta 1.

mickeyl avatar Jun 09 '22 09:06 mickeyl

Do we know when it will be fixed? Any work arounds while it is being fixed?

shahla00 avatar Jun 20 '22 21:06 shahla00

None. No progress reports, not even an acknowledgment. It's sad.

mickeyl avatar Aug 02 '22 09:08 mickeyl

Still a problem with Swift 5.9 beta as per Xcode 15 beta. I vaguely recall a discussion where someone said it's not going to be fixed, so it would probably be good to close this as WONTFIX. I'm not going to do this though, since it's not fixed.

mickeyl avatar Jun 09 '23 14:06 mickeyl