Having trouble with a Crash Report - EXC_BAD_ACCESS - objective-c

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?

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.

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.

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

Related

My Xcode version 8.0 crashes

My Xcode crashes, After crash occur, I updated it to the latest version, i.e 8.0
But it doesn't stop crashing.
Process: Xcode [528]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 8.0 (11246)
Build Info: IDEFrameworks-11246000000000000~3
App Item ID: 497799835
App External ID: 818744938
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [528]
User ID: 501
Date/Time: 2016-10-08 14:08:34.396 +0500
OS Version: Mac OS X 10.11.6 (15G1004)
Report Version: 11
Anonymous UUID: 844112AA-C988-B86A-8002-19E0765599D4
Time Awake Since Boot: 180 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:ProductBuildVersion: 8A218a
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks- 11246/IDEKit/Application/IDEWindowMenuController.m:101
Details: itemName should be a non-empty string, but it's an empty string
Object: <IDEWindowMenuController>
Method: +titleForItemWithURL:name:image:parentLocations:presentedParentLocationCount:includeIconInTitles:
Thread: <NSThread: 0x7fc74ad179f0>{number = 1, name = main}
Hints: None
Following is the Back Trace Report:
Backtrace:
0 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in IDEKit)
1 _DVTAssertionHandler (in DVTFoundation)
2 _DVTAssertionFailureHandler (in DVTFoundation)
3 +[IDEWindowMenuController titleForItemWithURL:name:image:parentLocations:presentedParentLocationCount:includeIconInTitles:] (in IDEKit)
4 __90+[IDEWindowMenuController _createAttributedTitlesForItemDictionaries:includeIconInTitles:]_block_invoke (in IDEKit)
5 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke (in CoreFoundation)
6 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] (in CoreFoundation)
7 +[IDEWindowMenuController _createAttributedTitlesForItemDictionaries:includeIconInTitles:] (in IDEKit)
8 -[IDEWindowMenuController _windowMenuItemsWithIconInTitles:] (in IDEKit)
9 -[IDEApplicationController applicationDockMenu:] (in IDEKit)
10 -[NSApplication _createDockMenu:] (in AppKit)
11 __44-[NSApplication _copyPublicPersistentUIInfo]_block_invoke (in AppKit)
12 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ (in CoreFoundation)
13 __CFRunLoopDoBlocks (in CoreFoundation)
14 __CFRunLoopRun (in CoreFoundation)
15 CFRunLoopRunSpecific (in CoreFoundation)
16 RunCurrentEventLoopInMode (in HIToolbox)
17 ReceiveNextEventCommon (in HIToolbox)
18 _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox)
19 _DPSNextEvent (in AppKit)
20 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit)
21 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in DVTKit)
22 -[NSApplication run] (in AppKit)
23 NSApplicationMain (in AppKit)
24 start (in libdyld.dylib)
abort() called
Application Specific Signatures:
![(itemName) isEqualToString:#""]
Try with these please :
Open Xcode
Preferences
Locations
The Derived Data option will tell you where your directory is
Delete that directory
Try to open your project
And check this thread also:
https://forums.developer.apple.com/thread/39603
This crash occurred due to problem in my project, so i was beginner, and I assumed that problem is in my X-Code.
The Project loaded automatically and causes crash to occur.
After opening some one previous project, and tried to stop this crashed project, Crashing stopped.. :P

Tracking down a SIGSEGV…

So I've got this weird SIGSEGV happening at very few (less than 1%) of my users…
From the stack trace it looks like an over-release
Thread 0 Crashed:
0 libobjc.A.dylib 0x00007fff9a3f916f objc_release + 31
1 libobjc.A.dylib 0x00007fff9a3f7ac4 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 475
2 CoreFoundation 0x00007fff9cc5c102 _CFAutoreleasePoolPop + 49
3 Foundation 0x00007fff96992cb6 -[NSAutoreleasePool drain] + 152
4 AppKit 0x00007fff9138409b -[NSApplication run] + 892
5 AppKit 0x00007fff91306520 NSApplicationMain + 1175
6 RailModeller Pro 0x000000010b60578b main (main.m:30)
7 libdyld.dylib 0x00007fff9a36b5ad start + 0
..but no matter what I try,
even with the very same data,
following the exact same steps as the users,
same OS/patch level,
using Address Sanitizer (Xcode 7.3),
using Zombies instrument,
using Guard Malloc
all appears to be fine.
The function crashing is a pretty common one in the app and I'd be drowning in bug reports (both from the automated bug reporting system as well as users getting in touch) if this were a more common issue.
However, to these (<1%) users the app appears effectively unusable.
Any hints on how to track down this issue much appreciated!

NSDocument is marked as dirty after a save due to NSUndoManager - why?

So I set a breakpoint on updateChangeCount:(NSDocumentChangeType)changeType to see when my document was being marked as dirty.
After I save the document, it is cleared properly with NSChangeCleared, then IMMEDIATELY after it is called with NSChangeDone which increments the changed count.
Here is the stack trace of that call:
0 SS 0x000000010000764a -[SSDocument updateChangeCount:] + 42
1 AppKit 0x00007fff94fdcdac -[NSDocument _changeWasDone:] + 458
2 CoreFoundation 0x00007fff9c415c9c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
3 CoreFoundation 0x00007fff9c415c2f ___CFXRegistrationPost_block_invoke + 63
4 CoreFoundation 0x00007fff9c415ba7 _CFXRegistrationPost + 407
5 CoreFoundation 0x00007fff9c415912 ___CFXNotificationPost_block_invoke + 50
6 CoreFoundation 0x00007fff9c3d26d2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1922
7 CoreFoundation 0x00007fff9c3d1925 _CFXNotificationPost + 693
8 Foundation 0x00007fff9b72b0fa -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
9 Foundation 0x00007fff9b7ba4ad -[NSUndoManager _endUndoGroupRemovingIfEmpty:] + 535
10 Foundation 0x00007fff9b79b06b +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 484
11 AppKit 0x00007fff94bd7dca -[NSApplication run] + 844
I haven't configured NSUndoManager in any way. Any suggestions on how I can prevent this from occurring?
It's a problem because a user can save the document, close the window, and they are then asked to save again.
Undo operations are typically collected in undo groups. NSUndoManager normally creates undo groups automatically during the run loop. The first time it is asked to record an undo operation in the run loop, it creates a new group. Then, at the end of the loop, it closes the group.
You can temporarily disable undo by calling -[NSUndoManager disableUndoRegistration] and -[NSUndoManager enableUndoRegistration]. You can remove all undo actions with -[NSUndoManager removeAllActions].

Can't figure out "Unrecognized selector sent to instance" source

So I am at my wit's end on this, I am toggling some sharedprefs back and forth, and eventually it makes my app crash. I thought it was because I wasn't deallocating observers properly, but upon looking at the crash log it says that an unrecognized selector is sent to instance. Does anybody know more about crash logs that can tell me more about what's happening? I can get the basic gist of what's happening out of the log, but I'm still a rookie and a lot of the information is going over my head.
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType _adjustLengthDueToViewFrameChange:]: unrecognized selector sent to instance 0x608000095b80'
terminating with uncaught exception of type NSException
abort() called
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff8fdcb25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff92afae75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8fdce12d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff8fd29272 ___forwarding___ + 1010
4 CoreFoundation 0x00007fff8fd28df8 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x00007fff8fd99e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
6 CoreFoundation 0x00007fff8fc8d82d _CFXNotificationPost + 2893
7 AppKit 0x00007fff915a4003 -[NSView _postFrameChangeNotification] + 434
8 AppKit 0x00007fff915ad6c2 -[NSView setFrameSize:] + 1586
9 AppKit 0x00007fff915ad049 -[NSView setFrame:] + 294
10 AppKit 0x00007fff915acc2b -[NSWindow setContentView:] + 453
11 AppKit 0x00007fff91beeace -[NSStatusItem setView:] + 224
12 MyAppHelper 0x00000001000775f5 -[NSStatusItem(BCStatusItem) setupView] + 85
13 MyAppHelper 0x000000010000cdbb -[MyAppHelperCapHelperServer createStatusBarItem] + 299
14 MyAppHelper 0x000000010000cf5b -[MyAppHelperCapHelperServer insertCaptureMenu] + 43
15 MyAppHelper 0x000000010000fe3d -[MyAppHelperHelperServer observeValueForKeyPath:ofObject:change:context:] + 733
16 Foundation 0x00007fff927e8f28 NSKeyValueNotifyObserver + 387
17 Foundation 0x00007fff927e80f8 NSKeyValueDidChange + 453
18 Foundation 0x00007fff927ecbe6 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 118
19 MyAppHelperHelper 0x0000000100109a3d __57-[RMSharedUserDefaults __applyBaselineAndNotify:updates:]_block_invoke + 349
20 CoreFoundation 0x00007fff8fd086df __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 111
21 CoreFoundation 0x00007fff8fd085ee -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 222
Primarily, I have no idea what it means in the exception information: [__NSCFType _adjustLengthDueToViewFrameChange:]. I cannot seem to find any information anywhere.
Thanks in advance!
First, I assume you are manually managing the memory, if so, I'll Highly recommend you to migrate to ARC (Automatic Reference Counting) it will manage the memory for you and you wont have this type or errors anymore. There are plenty of tutorials on Google of how to do this.
You can read more here: Transitioning to ARC Release Notes
Second, without ARC, this kind of error is often caused because you are calling a method/selector on an already released object, that's why the method/selector is not recognized.
This assuming you take care of clearing all the warnings on your project, if not, first go and check if there isn't a warning already pointing that you are trying to call a method/selector that doesn't exist for some object in your app. You can use the Analyze option as mentioned on the comments of this answer. To do that just Cmd+Shift+b, select the Analyze option from the Product Menu or Press and Hold the "Play" button you use to build the app and you will see the Analyze option as well.
Finally, I see you are using User Defaults. I'll recommend making sure you are retaining the values you are receiving from the User Defaults as they came with autorelease. This will explain why the compiler is not able to show the exact line of code where this error is happening, because it happens until the objet is autoreleased.
If is not the User Defaults I'll go and check all my autoreleased variables, is most likely that the problem is with one of them.

NSEvent charactersIgnoringModifiers randomly throws "TSMProcessRawKeyCode failed" exception

Our Mac cocos2d app (http://deepworldgame.com) has been randomly throwing "TSMProcessRawKeyCode failed" exceptions for some time now, and I'm wondering if anyone has experienced this error or knows how to prevent it.
It always happens via the [NSEvent charactersIgnoringModifiers] call within ccKeysDown or ccKeysUp (it also happens for [NSEvent characters] without the modifiers). I don't think it's related to specific keys. Sometimes it only happens one time and the app continues to function afterward (if the exception is caught), but other times it essentially locks up keyboard input indefinitely and continues to cause exceptions with all future keypresses (again, when these exceptions are caught).
I've found little on the internets regarding this issue, unfortunately. One place I did find was in the Adium source code (https://bitbucket.org/adium/adium/src/6d1f9b903525/Source/AIExceptionController.m), which catches this exception with the comments:
//Ignore various known harmless or unavoidable exceptions (From the system or system hacks)
...
// [TSMProcessRawKeyCode] May be raised by -[NSEvent charactersIgnoringModifiers]
It is indeed harmless when thrown once, but when the occasion happens that it continuously fires, it's a real problem - especially when you're in fullscreen mode and can't use cmd-F to escape!
So, if anyone has any thoughts or experience, I would be HIGHLY grateful. This is pretty much the one remaining superbug in our application, and I would love to squash it into dust.
Thanks!
Here is the typical stack trace (MacManager.m is our object which implements the cocos2d keyboard delegate protocol):
Crashed Thread: 7 CVDisplayLink
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Application Specific Information:
objc[28871]: garbage collection is OFF
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'TSMProcessRawKeyCode failed (-192)'
*** Call stack at first throw:
(
0 CoreFoundation 0x95b27d87 __raiseError + 231
1 libobjc.A.dylib 0x9315a149 objc_exception_throw + 155
2 CoreFoundation 0x95a8f619 +[NSException raise:format:arguments:] + 137
3 CoreFoundation 0x95a8f589 +[NSException raise:format:] + 57
4 AppKit 0x9ac01c1f _convertEventRefToString + 300
5 AppKit 0x9ab23b5e -[NSEvent charactersIgnoringModifiers] + 880
6 Deepworld 0x0001fd8a -[MacManager ccKeyDown:] + 65
7 CoreFoundation 0x95a7d091 -[NSObject performSelector:withObject:] + 65
8 Deepworld 0x0006bc95 -[CCEventDispatcher keyDown:] + 80
9 CoreFoundation 0x95a7d091 -[NSObject performSelector:withObject:] + 65
10 Deepworld 0x0006c014 -[CCEventDispatcher dispatchQueuedEvents] + 143
11 Deepworld 0x0006a9a4 -[CCDirectorDisplayLink getFrameForTime:] + 155
12 Deepworld 0x0006aaf1 MyDisplayLinkCallback + 40
13 CoreVideo 0x9b44a5e1 _ZN13CVDisplayLink9performIOEP11CVTimeStamp + 489
14 CoreVideo 0x9b4494e4 _ZN13CVDisplayLink11runIOThreadEv + 876
15 CoreVideo 0x9b449161 _ZL13startIOThreadPv + 160
16 libsystem_c.dylib 0x968a4ed9 _pthread_start + 335
17 libsystem_c.dylib 0x968a86de thread_start + 34
)
I don't think sending events in general is thread-safe, not to mention from a thread that has been created not within +[NSThread detachNewThreadSelector:toTarget:withObject:] (a thread created using the Objective-C run-time has __NSThread__main__ in the backtrace).
I guess your app is the Deepworld binary part - when dispatching events, try using -[NSObject performSelectorOnMainThread:waitUntilDone:] instead, dispatching the events on the main thread.