Raesu
Raesu

Reputation: 310

Swift crash report function signature specialization Owned To Guaranteed

A number of my users started getting a crash after I rewrote some Objective-C code in Swift. I cannot reproduce at all when linked to Xcode, and I cannot figure out why only a few of my users are getting the crash. I retrieved the logs from HockeyApp and the reason stated is: Selector name found in current argument registers: registeredContacts. This is an array I am dealing with in my code but under no circumstance can I get it to crash in relation to accessing or setting that array.

I think it may be my Swift block syntax and how I am calling it from Objective-C. My Swift function signature:

func retrieveActivities(handler: (([WPActivity], Error?) -> Void)?) {

and I am calling it in Objective-C with:

[[WPActivitiesManager shared] retrieveActivitiesWithHandler:nil];

Sometimes I do use the block but on startup I do not need it. As I said, this does not crash for me and there are no compiler warnings.

The top of my crash log:

Exception Type:  SIGTRAP
Exception Codes: #0 at 0x1001c0438
Crashed Thread:  0

Application Specific Information:
Selector name found in current argument registers: registeredContacts

Thread 0 Crashed:
0   Waypoint                             0x00000001001c0438 function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Owned To Guaranteed> of Waypoint.WPActivitiesManager.(retrieveActivities (handler : ([__ObjC.WPActivity], Swift.Error?) -> ()?) -> ()).(closure #2) with unmangled suffix "_merged" + 612
1   Waypoint                             0x00000001001c13a4 partial apply forwarder for Waypoint.WPActivitiesManager.(retrieveActivities (handler : ([__ObjC.WPActivity], Swift.Error?) -> ()?) -> ()).(closure #2) with unmangled suffix "_merged" + 64
2   Foundation                           0x0000000189ca2754 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
3   Foundation                           0x0000000189be72c8 -[NSBlockOperation main] + 92
4   Foundation                           0x0000000189bd78c4 -[__NSOperationInternal _start:] + 616
5   Foundation                           0x0000000189ca4b00 __NSOQSchedule_f + 224
6   libdispatch.dylib                    0x00000001880691c0 _dispatch_client_callout + 12
7   libdispatch.dylib                    0x000000018806dd6c _dispatch_main_queue_callback_4CF + 996
8   CoreFoundation                       0x000000018918bf2c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
9   CoreFoundation                       0x0000000189189b18 __CFRunLoopRun + 1656
10  CoreFoundation                       0x00000001890b8048 CFRunLoopRunSpecific + 440
11  GraphicsServices                     0x000000018ab3e198 GSEventRunModal + 176
12  UIKit                                0x000000018f0a42fc -[UIApplication _run] + 680
13  UIKit                                0x000000018f09f034 UIApplicationMain + 204
14  Waypoint                             0x0000000100122888 main (main.m:14)
15  libdyld.dylib                        0x000000018809c5b8 start + 0

I suspect the registeredContacts comment (added by HockeyApp I believe) is not relevant here but it is an ObjC/Swift issue. Any ideas appreciated.

The log is finally available in Xcode and I have this additional info:

Xcode log

Upvotes: 0

Views: 1161

Answers (1)

matt
matt

Reputation: 535801

I suspect the registeredContacts comment (added by HockeyApp I believe) is not relevant here

No, I think you have it backwards. That is exactly what is relevant. It is your crash report that is not relevant.

SIGTRAP merely means that we got an exception. The exception is being thrown in the code (or rather, in the course of executing the code). But you don't seem to be getting any info as to what it is. My guess is that HockeyApp is actually interfering with your receiving the real report, which would tell you what the exception was.

The problem is thus somewhere in retrieveActivities. You might try to guess where by counting lines (you are told the number of lines into your method where the crash actually happens). It could be something as simple as out-of-bounds array access, I believe. The fact that an array registeredContacts is popping up here is thus quite suggestive. Look for a registeredContacts access at about that point in the method.

Upvotes: 2

Related Questions