You are on page 1of 51

Debug Debug

Crash Report
a.k.a zonble
zonble@gmail.com

12615


KKBOX
KKBOX Mac/iOS Client
Yahoo! X1
OpenVanilla

iPhoneetc
12615



code bug

Crash Report


https://github.com/zonble/Crashy
12615


Crash Report
Crash Report
EXC_BAD_ACCESS
EXC_CRASH
failed to resume in time
Bug
12615

bug

bug

spec bug
Crash

Framework OS
app kill

12615

Bug
DebuggerGDBLLDB
Crash Report

12615

Crash Report

Xcode -> Organizer


Console.app
iTunes Connect
QuincyKit
12615

12615

12615

Crash Report


Thread

12615

50 pin iOS

Device Xcode
crash log

gdb/lldb backtrace

12615

Crash Back Trace


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

0x3629632c 0x36285000 + 70444
1 libsystem_c.dylib


0x32de2208 0x32d95000 + 315912
2 libsystem_c.dylib


0x32ddb298 0x32d95000 + 287384
3 libsystem_c.dylib


0x32dedefa 0x32d95000 + 364282
4 libsystem_c.dylib


0x32deeb2a 0x32d95000 + 367402
5 libsystem_c.dylib


0x32d99934 0x32d95000 + 18740
6 CoreFoundation

0x35929730 0x35927000 + 10032
7 CoreFoundation

0x359296a4 0x35927000 + 9892
8 Crashy

0x000037dc -[CCRootTableViewController tableView:didSelectRowAtIndexPath:]
(CCRootTableViewController.m:157)
9 UIKit

0x334c6936 0x33411000 + 743734
10 UIKit

0x33540620 0x33411000 + 1242656
11 Foundation


0x354fa92c 0x3545f000 + 637228
12 CoreFoundation

0x359b4a2c 0x35927000 + 580140
13 CoreFoundation

0x359b4692 0x35927000 + 579218
14 CoreFoundation

0x359b3268 0x35927000 + 574056
15 CoreFoundation

0x3593649e 0x35927000 + 62622
16 CoreFoundation

0x35936366 0x35927000 + 62310
17 GraphicsServices

0x375d2432 0x375ce000 + 17458
18 UIKit

0x33442cce 0x33411000 + 203982
19 Crashy

0x00002ca6 main (main.m:7)
20 Crashy

0x00002c4c start + 32
12615


log

Tester
release

12615

log
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib

0x3629632c 0x36285000 + 70444
1 libsystem_c.dylib


0x32de2208 0x32d95000 + 315912
2 libsystem_c.dylib


0x32ddb298 0x32d95000 + 287384
3 libsystem_c.dylib


0x32dedefa 0x32d95000 + 364282
4 libsystem_c.dylib


0x32deeb2a 0x32d95000 + 367402
5 libsystem_c.dylib


0x32d99934 0x32d95000 + 18740
6 CoreFoundation

0x35929730 0x35927000 + 10032
7 CoreFoundation

0x359296a4 0x35927000 + 9892
8 Crashy

0x000157dc 0x13000 + 10204
9 UIKit

0x334c6936 0x33411000 + 743734
10 UIKit

0x33540620 0x33411000 + 1242656
11 Foundation


0x354fa92c 0x3545f000 + 637228
12 CoreFoundation

0x359b4a2c 0x35927000 + 580140
13 CoreFoundation

0x359b4692 0x35927000 + 579218
14 CoreFoundation

0x359b3268 0x35927000 + 574056
15 CoreFoundation

0x3593649e 0x35927000 + 62622
16 CoreFoundation

0x35936366 0x35927000 + 62310
17 GraphicsServices

0x375d2432 0x375ce000 + 17458
18 UIKit

0x33442cce 0x33411000 + 203982
19 Crashy

0x00014ca6 0x13000 + 7334
20 Crashy

0x00014c4c 0x13000 + 7244

12615

Debug
Symbol
tester
Xcode Archive

git revision

Xcode

Jenkins CI
12615

Debug Symbol
.app.dSYM bundle
bundle

<YourApp>.app.dSYM/Contents/Resources/
DWARF

12615

atos

atos -arch armv7 -o <YOUR BINARY> -l
<LOAD ADDRESS> <ADDRESS>

12615

12615

EXC_BAD_ACCESS

12615



ARC


getter retain
dealloc release
method auto release
12615


Notifications
Push Notification
Notification Center

addObserver dealloc
removeObserver:self

KVO
12615

EXC_CRASH

12615

Exception
Array
addObject:setObject:forKey: nil
selector

12615

Raising Exceptions
assert
NSAssert
-DNS_BLOCK_ASSERTIONS=1
release build NSAssert

[NSException raise: format:]


12615

Try Catch
@try @catch
NSException
JavaPython

@try

@catch
NSException

12615

NSErrorNSException

NSError

NSError

NSException
12615

Exception
Crash Log

12615

thread

Thread 0 Crashed:
0 libsystem_kernel.dylib
1 libsystem_c.dylib
2 libsystem_c.dylib
3 libc++abi.dylib
4 libc++abi.dylib
5 libobjc.A.dylib
6 libc++abi.dylib
7 libc++abi.dylib
8 libc++abi.dylib
9 libobjc.A.dylib
10 CoreFoundation
11 CoreFoundation
12 GraphicsServices
13 UIKit
14 Crashy
15 Crashy


0x3629632c __pthread_kill + 8
0x32de2208 pthread_kill + 48
0x32ddb298 abort + 88
0x35d98f64 abort_message + 40
0x35d96346 _ZL17default_terminatev + 18
0x37d87350 _objc_terminate + 140
0x35d963be _ZL19safe_handler_callerPFvvE + 70
0x35d9644a std::terminate() + 14
0x35d9781e __cxa_rethrow + 82
0x37d872a2 objc_exception_rethrow + 6


0x35936506 CFRunLoopRunSpecific + 398


0x35936366 CFRunLoopRunInMode + 98

0x375d2432 GSEventRunModal + 130
0x33442cce UIApplicationMain + 1074
0x00009ca6 main (main.m:7)
0x00009c4c start + 32

throw Exception kill


12615

Last Exception
Backtrace
Last Exception Backtrace:
0 CoreFoundation

0x359e088f __exceptionPreprocess + 163
1 libobjc.A.dylib

0x37d87259 objc_exception_throw + 33
2 CoreFoundation

0x359351d7 -[__NSArrayM insertObject:atIndex:] + 187
3 Crashy

0x0000a9a7 -[CCRootTableViewController
tableView:didSelectRowAtIndexPath:] (CCRootTableViewController.m:191)
4 UIKit

0x334c693d -[UITableView
_selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 945
5 UIKit

0x33540627 -[UITableView
_userSelectRowAtPendingSelectionIndexPath:] + 159
6 Foundation

0x354fa933 __NSFireDelayedPerform + 415
7 CoreFoundation

0x359b4a33
__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 15
8 CoreFoundation

0x359b4699 __CFRunLoopDoTimer + 365
9 CoreFoundation

0x359b326f __CFRunLoopRun + 1207
10 CoreFoundation


0x359364a5 CFRunLoopRunSpecific + 301
11 CoreFoundation


0x3593636d CFRunLoopRunInMode + 105
12 GraphicsServices

0x375d2439 GSEventRunModal + 137
13 UIKit


0x33442cd5 UIApplicationMain + 1081

12615


Last Exception Backtrace:
(0x359e088f 0x37d87259 0x359351d7 0xa9a7
0x334c693d 0x33540627 0x354fa933 0x359b4a33
0x359b4699 0x359b326f 0x359364a5 0x3593636d
0x375d2439 0x33442cd5 0x9cad 0x9c54)
atos

12615

Console Log
Exception Console Log

Crash Report

12615

UIKit

12615


- (void)loadView
{

self.view;
}
# self.view nil -loadView

12615


[aView addSubView:aView]
# UIKit

12615

push
Navigation Controller
UINavigationController *navController =
[[UINavigationController alloc]
initWithRootViewController:nil];
[self.navigationController
pushViewController:navController
animated:YES];
[navController release];
12615


UIViewController *viewController =
[[UIViewController alloc] init];
[self.navigationController
pushViewController:viewController animated:YES];
[self.navigationController
performSelector:@selector(popToRootViewController
Animated:) withObject:nil afterDelay:0.1];
[viewController release];
# Push 0.25
12615

failed to resume in time

12615

Console Log
Jun 3 02:08:06 unknown SpringBoard[15] <Warning>:
net.zonble.Crashy failed to resume in time
Jun 3 02:08:06 unknown SpringBoard[15] <Warning>:
Forcing crash report of Crashy[1473]...
Jun 3 02:08:07 unknown SpringBoard[15] <Warning>:
Finished crash reporting.

12615

Crash Report
Exception Type: 00000020
Exception Codes: 0x8badf00d
Highlighted Thread: 0
Application Specific Information:
net.zonble.Crashy failed to launch in time
Elapsed total CPU time (seconds): 21.560 (user 21.560,
system 0.000), 54% CPU
Elapsed application CPU time (seconds): 19.573, 49%
CPU
12615

failed to resume in time


application:

didFinishLaunchingWithOptions:
kill

performSelector: withObject: afterDelay:


dispatch_after
12615

Protocol/Delegate

12615

delegate
@protocol CCBuggyObjectDelegate <NSObject>
- (void)buggyObjectWillStart:(CCBuggyObject *)inObject;
- (void)buggyObjectDidStart:(CCBuggyObject *)inObject;
- (void)buggyObjectWillStop:(CCBuggyObject *)inObject;
- (void)buggyObjectDidStop:(CCBuggyObject *)inObject;
@end
@interface CCBuggyObject : NSObject {

id <CCBuggyObjectDelegate> delegate;
}
- (void)start;
- (void)stop;
@property (assign, nonatomic) id <CCBuggyObjectDelegate> delegate;
@end
12615


- (void)start
{

NSLog(@"start step 1");

[delegate buggyObjectWillStart:self];

NSLog(@"start step 2");

[delegate buggyObjectDidStart:self];

}
- (void)stop
{

NSLog(@"Stop step 1");

[delegate buggyObjectWillStop:self];

NSLog(@"Stop step 2");

[delegate buggyObjectDidStop:self];

}

12615

delegate method

- (void)buggyObjectWillStart:(CCBuggyObject *)inObject
{

[inObject start]; #
}
- (void)buggyObjectWillStart:(CCBuggyObject *)inObject
{

[inObject release]; #
}

12615

Table View
Delegate :)
- (NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView
{
[tableView reloadData];
return 1;
}
# Table View Data Source Delegate method
Data Source method reloadData

12615


- (void)buggyObjectWillStart:(CCBuggyObject *)inObject
{
if (something_happens()) {
[inObject stop];
}
}
#

12615

start

- (void)start
{

NSLog(@"start step 1");

[delegate buggyObjectWillStart:self];
stop start step 2
stop start code


NSLog(@"start step 2");

[delegate buggyObjectDidStart:self];

}
12615

stop

- (void)start {
stopEverCalled = YES;
// start step 1;
[delegate buggyObjectWillStart:self];
if (stopEverCalled) return;
#
// start step 2;
[delegate buggyObjectDidStart:self];

}
- (void)stop {
stopEverCalled = YES;
// Do something
}

12615


@protocol CCBuggyObjectDelegate <NSObject>
- (BOOL)buggyObjectShouldStart:(CCBuggyObject
*)inObject;
- (void)buggyObjectDidStart:(CCBuggyObject *)inObject;
- (BOOL)buggyObjectShouldStop:(CCBuggyObject
*)inObject;
- (void)buggyObjectDidStop:(CCBuggyObject *)inObject;
@end

12615


- (void)start
{
// start step 1;
if (![delegate buggyObjectShouldStart:self]) {
return;
}
// start step 2;
[delegate buggyObjectDidStart:self];

}
12615

Das ist alles

12615