Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having trouble with a Crash Report - EXC_BAD_ACCESS

OK, SO I've received a crash report for one of my apps, but I swear I'm 100% confused.

This is what the "core" part of it looks like :

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

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000

VM Regions Near 0:
--> 
    __TEXT                 0000000100000000-0000000100015000 [   84K] r-x/rwx SM=COW  /Applications/MY_APP/Contents/MacOS/MY_APP

Application Specific Information:
objc[337]: garbage collection is ON

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_c.dylib               0x00007fff90128650 strlen + 16
1   MY_BUNDLE_ID                    0x0000000100008f12 0x100000000 + 36626
2   MY_BUNDLE_ID                    0x000000010000b435 0x100000000 + 46133
3   MY_BUNDLE_ID                    0x0000000100003c90 0x100000000 + 15504
4   com.apple.CoreFoundation        0x00007fff9065147a _CFXNotificationPost + 2554
5   com.apple.Foundation            0x00007fff8e5fe846 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
6   com.apple.AppKit                0x00007fff9a7894a7 -[NSTableView textDidChange:] + 377
7   com.apple.CoreFoundation        0x00007fff9065147a _CFXNotificationPost + 2554
8   com.apple.Foundation            0x00007fff8e5fe846 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
9   com.apple.AppKit                0x00007fff9a15c260 -[NSTextView(NSSharing) didChangeText] + 339
10  com.apple.AppKit                0x00007fff9a7f8381 _NSDoUserReplaceForCharRange + 390
11  com.apple.AppKit                0x00007fff9a7f85b1 _NSDoUserDeleteForCharRange + 38
12  com.apple.AppKit                0x00007fff9a7e1e72 -[NSTextView(NSKeyBindingCommands) deleteBackward:] + 440
13  com.apple.AppKit                0x00007fff9a18a1cc -[NSResponder doCommandBySelector:] + 75
14  com.apple.AppKit                0x00007fff9a18a02e -[NSTextView doCommandBySelector:] + 197
15  com.apple.AppKit                0x00007fff9a20cf4e -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 2200
16  com.apple.AppKit                0x00007fff9a20c3bb -[NSTextInputContext handleEvent:] + 939
17  com.apple.AppKit                0x00007fff9a20bf87 -[NSView interpretKeyEvents:] + 183
18  com.apple.AppKit                0x00007fff9a158f67 -[NSTextView keyDown:] + 723
19  com.apple.AppKit                0x00007fff9a374120 -[NSWindow sendEvent:] + 9687
20  com.apple.AppKit                0x00007fff9a36f744 -[NSApplication sendEvent:] + 5761
21  com.apple.AppKit                0x00007fff9a2852fa -[NSApplication run] + 636
22  com.apple.AppKit                0x00007fff9a229cb6 NSApplicationMain + 869
23  MY_BUNDLE_ID                        0x0000000100002014 0x100000000 + 8212

Do you have any idea what might be going wrong? Or could you just point me to the right direction?


As an aside :

Could anyone guide me how to make e.g. 0x00007fff90128650 more... meaningful and make it (in some future crash report) also show the name of the function?

like image 693
Dr.Kameleon Avatar asked Dec 12 '22 21:12

Dr.Kameleon


1 Answers

Your crash log give you lot of informations: first you crashed because you tried to access to address 0 into ur program and kernel is not happy.

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000

See, you get a segmentation, by the way it's starting to the 0x00 address, so it's like you're directly accessing a 0 / nil pointer. Like this

char* adress = 0;
printf("get %p", adress); // will output 0x0
printf("get %p", adress[0]); // will make a EXC_BAD_ACCESS

You should really focus on this.

From the crash stack there is three interesting things:

6   com.apple.AppKit                0x00007fff9a7894a7 -[NSTableView textDidChange:] + 377
 5   com.apple.Foundation            0x00007fff8e5fe846 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
    0   libsystem_c.dylib               0x00007fff90128650 strlen + 16

[textDidChange] is one of the last call who caused the crash, by the way you're sending a notification when the [textDidChange] is fired. And last line who actually make the crash: strlen + 16 is because there's something who think it can get a char length from a valid pointer address and it's actually not the case.

According to me, you should check what you're sending into your notification.

_NSDoUserReplaceForCharRange
  _NSDoUserDeleteForCharRange

When you look deeply into the stack crash, it really seems that's it's appearing when you make cell - insertion / deletion into ur tableViewController. You should check that sometime someone push invalid data, or not using the edit cell the way it's supposed to be.

So here's the resume: 1 Someone edit a tableViewCell, he doesn't insert or code doesn't insert what it's supposed to be. 2 You're sending a notification with a non-valid data inside it. 3 When the strlen(invalid_dataStructure) is fired, it make ur app crash

By the way i'm just "guessing", since i don't know actually your code implementation. But i hope it can give you lots of clues for your debugging session.

like image 87
Mr Bonjour Avatar answered Dec 29 '22 04:12

Mr Bonjour