Unable to find cause of error "EXC_BAD_INSTRUCTION (SIGILL)"

Hi there,


I hope I'm posting this question in the right category.


I develop a Clock app for macOS which is on the Mac App Store. Just within the last week, a user from Switzerland got in touch with me about some issues he was having. At first, I thought the set of issues he was experiencing had to do with some problems I had recently been dealing with. An update was on the way and assured him that the update would most assuredly fix his problems, but if it didn't, he could email me back. Unfortunately, he emailed me back telling me that the entire app was now broken, it was crashing on launch. I did quite a bit of troubleshooting after that trying to reproduce the problem but wasn't able to. This is also the only incident of this kind that I know of, no one else has contacted me with this problem. He sent me the crash log and I watched this presentation at WWDC18 to learn more about crash logs. A lot of what was said went over my head, I'm no rocket scientist, but I think I got the gist of it and it has helped grow my brain somewhat. Nevertheless, I'm still really confused with the error that I'm dealing with.



So here's the crash log:


Process:               Clock Pro [608]
Path:                  /Applications/Clock Pro.app/Contents/MacOS/Clock Pro
Identifier:            com.mnccoding.Clock
Version:               1.3.8 (46)
App Item ID:           1107473342
App External ID:       833098719
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Clock Pro [608]
User ID:               501

Date/Time:             2019-10-16 09:21:34.391 +0200
OS Version:            Mac OS X 10.13.6 (17G8037)
Report Version:        12
Anonymous UUID:        DB6FF886-129B-CF54-B3CC-607E5BF9FEBA


Time Awake Since Boot: 200 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Illegal instruction: 4
Termination Reason:    Namespace SIGNAL, Code 0x4
Terminating Process:   exc handler [0]

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.mnccoding.Clock           0x00000001005bab1d 0x1005b1000 + 39709
1   com.mnccoding.Clock           0x00000001005bb018 0x1005b1000 + 40984
2   com.apple.AppKit              0x00007fff35f9d20a -[NSViewController _sendViewDidLoad] + 97
3   com.apple.AppKit              0x00007fff36541afd _noteLoadCompletionForObject + 641
4   com.apple.AppKit              0x00007fff35f21945 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 2042
5   com.apple.AppKit              0x00007fff3601cd1e -[NSNib _instantiateNibWithExternalNameTable:options:] + 679
6   com.apple.AppKit              0x00007fff3601c97a -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 136
7   com.apple.AppKit              0x00007fff3601bc50 -[NSViewController loadView] + 343
8   com.apple.AppKit              0x00007fff35f93a9e -[NSViewController _loadViewIfRequired] + 75
9   com.apple.AppKit              0x00007fff35f93a09 -[NSViewController view] + 30
10  com.apple.AppKit              0x00007fff36112365 -[NSWindow _contentViewControllerChanged] + 109
11  com.apple.Foundation          0x00007fff3aade6ce -[NSObject(NSKeyValueCoding) setValue:forKey:] + 331
12  com.apple.AppKit              0x00007fff361550c5 -[NSWindow setValue:forKey:] + 111
13  com.apple.AppKit              0x00007fff36155029 -[NSIBUserDefinedRuntimeAttributesConnector establishConnection] + 637
14  com.apple.AppKit              0x00007fff35f216e1 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1430
15  com.apple.AppKit              0x00007fff3601cd1e -[NSNib _instantiateNibWithExternalNameTable:options:] + 679
16  com.apple.AppKit              0x00007fff3601c97a -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 136
17  com.apple.AppKit              0x00007fff3677346c -[NSStoryboard instantiateControllerWithIdentifier:] + 236
18  com.apple.AppKit              0x00007fff35f159ef NSApplicationMain + 729
19  com.mnccoding.Clock           0x00000001005b4839 0x1005b1000 + 14393
20  libdyld.dylib                 0x00007fff608ea015 start + 1

Since my app is crashing on launch, I suspect that something in viewDidLoad( ) is causing it to crash, but I am unsure because I am not able to reproduce this issue and the above crash log is Greek to me.


This is not the entire log, there are other threads as well, but since I have not set up my app for multithreading, I have not included them. I can also include my code in viewDidLoad( ) if that will be helpful.


Help would be appreciated! I'm really confused!

Could you show the code for viewDidLoad.

And also applicationDidFinishLaunching.


In fat, it would even be better to post the complete

class AppDelegate


Read this old thread.

https://forums.developer.apple.com/thread/28032

SIGILL is very common in Swift (for example, when you unwrap a nil optional, or access outside of an array’s bounds).

As Claude31 mentioned, the

SIGILL
most likely indicates that you’ve hit a Swift trap. As to what’s triggering that trap, frame 2 of the backtrace strongly suggests that it’s related to your
-viewDidLoad
method. To debug this further you need to uncover the identity of frames 1 through 0.
0 com.mnccoding.Clock … 0x1005b1000 + 39709  
1 com.mnccoding.Clock … 0x1005b1000 + 40984  
2 com.apple.AppKit    … -[NSViewController _sendViewDidLoad] + 97

That requires you to symbolicate your log. A good place to learn about that process is Technote 2151 Understanding and Analyzing iOS Application Crash Reports (which technote is iOS-specific, most of the stuff about symbolication applies to all our platforms0.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Unable to find cause of error "EXC_BAD_INSTRUCTION (SIGILL)"
 
 
Q