Having trouble with a Crash Report - EXC_BAD_ACCESS

谁说胖子不能爱 提交于 2019-12-05 01:22:05

问题


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?


回答1:


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.




回答2:


Usually the problem is that you need a "retain" property.

You need to enable Zombies for debug mode. in xCode 4 click "edit scheme"->"Diagnostics"->"Enable Zombie Objects"

It will show you in console what "removed" object you try to access when crashing.

this should help.

you will see somthing like this:

2010-01-25 14:35:24.840 MyApplication[1393:20b] *** -[CFString retain]: message sent to deallocated instance 0x42a5060

You can also enable "Malloc logging" and after crash enter such command in debug console:

shell malloc_history 1393 0x42a5060

there you can find all alloc/release stack. just look at release and alloc commands.




回答3:


I got a very similar crash report trying to open graphic-heavy applications (pymol and coot) (See below)

I found out that if I disconnected my mac from my external monitor, the programs worked again. I was using a USB-HDMI connector - apparently this is a bad idea. I just purchased a microUSB-HDMI connector and I expect this will work better. The programs run if I just use my mac book's own monitor display.

Time Awake Since Boot: 19000 seconds
Time Since Wake:       110 seconds

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-0000000100cff000 [ 13.0M] r-x/rwx SM=COW  /Applications/MacPyMOL.app/Contents/MacOS/MacPyMOL

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.opengl                0x00007fff8333857c CGLDescribeRenderer + 79
1   com.schrodinger.macpymol        0x000000010083c5b4 CheckOpenGLCaps + 484
2   com.schrodinger.macpymol        0x000000010084cd8c -[PyMOLOpenGLView awakeFromNib] + 1420
3   com.apple.CoreFoundation        0x00007fff8a10785f -[NSSet makeObjectsPerformSelector:] + 223
4   com.apple.AppKit                0x00007fff88b935cd -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1216
5   com.apple.AppKit                0x00007fff886a3605 loadNib + 384
6   com.apple.AppKit                0x00007fff88c14749 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 727
7   com.apple.AppKit                0x00007fff88c14ca8 +[NSBundle(NSNibLoadingInternal) _loadNibFile:externalNameTable:options:withZone:] + 150
8   com.apple.AppKit                0x00007fff886a2bc0 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 631
9   com.schrodinger.macpymol        0x000000010084d77b main + 1499
10  com.schrodinger.macpymol        0x0000000100007494 start + 52


来源:https://stackoverflow.com/questions/12878966/having-trouble-with-a-crash-report-exc-bad-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!