SIGABRT inside GCD with iOS 6.1 - ios

We're having a weird crash inside libdispatch internal functions and after hours and hour of research we have no clue about what's happening.
The crash trace is:
Incident Identifier: 7A5CBCD8-28A3-4AC5-937A-D5BA69A64B67
CrashReporter Key: [TODO]
Hardware Model: iPhone5,2
Process: Memoir Dev [6973]
Path: /Users/USER/Memoir Dev.app/Memoir Dev
Identifier: com.veri.memoir-enterprise
Version: 0.9.191
Code Type: ARM
Parent Process: launchd [1]
Date/Time: 2013-03-03 20:55:42 +0000
OS Version: iPhone OS 6.1.2 (10B146)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x3ae66350
Crashed Thread: 1
Thread 0:
0 libsystem_kernel.dylib 0x3ae55e30 _mach_msg_trap + 20
1 CoreFoundation 0x000972bb __CFRunLoopServiceMachPort + 131
2 CoreFoundation 0x00095fdb __CFRunLoopRun + 819
3 CoreFoundation 0x32bc823d _CFRunLoopRunSpecific + 357
4 CoreFoundation 0x32bc80c9 _CFRunLoopRunInMode + 105
5 GraphicsServices 0x367a633b _GSEventRunModal + 75
6 UIKit 0x34ae42b9 _UIApplicationMain + 1121
7 Memoir Dev 0x0002a0d7 main (main.m:20)
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x3ae66350 ___pthread_kill + 8
1 libsystem_c.dylib 0x3ae1936b _abort + 95
2 libsystem_c.dylib 0x3adb212d _free + 361
3 libdispatch.dylib 0x000088d1 _dispatch_kevent_register + 169
4 libdispatch.dylib 0x00007e91 _dispatch_source_kevent_register + 33
5 libdispatch.dylib 0x00008957 _dispatch_timer_list_update + 27
6 libdispatch.dylib 0x00006b81 _dispatch_mgr_invoke + 389
7 libdispatch.dylib 0x00002378 _dispatch_mgr_thread + 36
Thread 2:
0 libsystem_kernel.dylib 0x3ae55e30 _mach_msg_trap + 20
[...]
A bit of background about our code and scenario:
We're using extensively NSOperations and GCD to upload data to our server
The crash seems to happen when the app is uploading in background, within the 10 minutes limit
The crash started to happen around feb/9 using iOS 6.1 (10B143), just few days after we upgrade from 6.0.2 to 6.1
Until now we can reproduce it in iOS 6.1.2 (10B146) but don't in 6.0.1 (10A523)
Regarding SIGABRT exception type, it seems someone is calling 'abort' function (indeed, it's 'free' called by 'dispatch_kevent_register')
Does any of you know if there's any known issue inside GCD in iOS 6.1 and later?

This is free() aborting due to heap corruption in the process.
The dispatch manager thread being the one to hit the abort() is likely incidental (the backtrace indicates it woke up to asynchronously install a new dispatch timer source and malloc detected the corruption at that time).
You may want to try running with GuardMalloc (see Diagnostics tab in XCode scheme editor), it is more likely to give you a crashpoint when the corruption actually occurs.
Alternatively the various malloc debug environment variables may help track down the culprit, c.f. ENVIRONMENT in malloc(3)

Related

React Native ios app crashes when run outside of xcode with failed to scene-create after 19.88s error

My react native app is crashing when launched outside of Xcode with the following exception showing up in the crash report on the device logs for thread 0.
Incident Identifier: DB5E0F81-977F-44B0-BD8B-FAAF33F98119
CrashReporter Key: e3b8d0751b47b37db0d7d6fcc5dde46051f8d30c
Hardware Model: iPhone7,1
Process: crashTest [388]
Path: /var/mobile/Containers/Bundle/Application/CE56E818-7288-4A39-8220-16E17158C916/crashTest.app/crashTest
Identifier: org.reactjs.native.example.crashTest
Version: 1 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2017-04-25 12:42:30.30 -0400
Launch Time: 2017-04-25 12:42:10.10 -0400
OS Version: iOS 9.1 (13B143)
Report Version: 105
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Exception Note: SIMULATED (this is NOT a crash)
Highlighted by Thread: 0
Application Specific Information:
org.reactjs.native.example.crashTest failed to scene-create after 19.92s (launch took 0.08s of total time limit 20.00s)
Elapsed total CPU time (seconds): 9.230 (user 9.230, system 0.000), 23% CPU
Elapsed application CPU time (seconds): 0.113, 0% CPU
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x0000000199ff0a7c semaphore_wait_trap + 8
1 libdispatch.dylib 0x0000000199ece614 _dispatch_semaphore_wait_slow + 244
2 CFNetwork 0x0000000184246ac0 CFURLConnectionSendSynchronousRequest + 288
3 CFNetwork 0x000000018426a07c +[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 120
4 crashTest 0x0000000100128858 -[RCTBundleURLProvider isPackagerRunning:] (RCTBundleURLProvider.m:76)
5 crashTest 0x0000000100128b00 -[RCTBundleURLProvider guessPackagerHost] (RCTBundleURLProvider.m:92)
6 crashTest 0x0000000100128d10 -[RCTBundleURLProvider packagerServerHost] (RCTBundleURLProvider.m:106)
7 crashTest 0x0000000100128ed4 -[RCTBundleURLProvider jsBundleURLForBundleRoot:fallbackResource:] (RCTBundleURLProvider.m:123)
8 crashTest 0x000000010006a8cc -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:21)
9 UIKit 0x000000018a0f5324 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400
10 UIKit 0x000000018a323acc -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904
11 UIKit 0x000000018a327e0c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1656
12 UIKit 0x000000018a324f50 -[UIApplication workspaceDidEndTransaction:] + 168
13 FrontBoardServices 0x000000018e90b7c4 -[FBSSerialQueue _performNext] + 184
14 FrontBoardServices 0x000000018e90bb44 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
15 CoreFoundation 0x0000000184aa4544 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
16 CoreFoundation 0x0000000184aa3fd8 __CFRunLoopDoSources0 + 540
17 CoreFoundation 0x0000000184aa1cd8 __CFRunLoopRun + 724
18 CoreFoundation 0x00000001849d0ca0 CFRunLoopRunSpecific + 384
19 UIKit 0x000000018a0ee1c8 -[UIApplication _run] + 460
20 UIKit 0x000000018a0e8ffc UIApplicationMain + 204
21 crashTest 0x000000010006ad08 main (main.m:16)
22 libdyld.dylib 0x0000000199eee8b8 start + 4
I understand that my app is taking too long to launch and display. If I run directly from Xcode with my device tethered there are no issues (but it does take forever to launch)
I am testing this with the default react project produced with react-native init
When I build the project in Xcode I see the following warning:
[tid:com.facebook.react.JavaScript][RCTModuleData.mm:220] RCTBridge required dispatch_sync to load RCTDevSettings. This may lead to deadlocks
I am new to react-native, and I am assuming maybe this is running in some sort of dev mode that does not allow me to launch the app when un-tethered or on a different network? Are there special instructions I am missing that I need to follow when building the app to run independently on the device without having to archive the app in Xcode?
Check if you're connected to the same WiFi network. Just had this.
In your -[AppDelegate application:didFinishLaunchingWithOptions:] function you're kicking off a synchronous network request, and that request appears to be taking too long. iOS kills your app because it has failed to finish launching (specifically, it's failed to return from application:didFinishLaunchingWithOptions:) after 20 seconds.
I've run into the same issue, and don't have a solution, but a temporary workaround that helped me. I've posted it here - https://github.com/facebook/react-native/issues/10187 in the hopes that someone better versed with objective-c and url loading will take a look and put in the proper fix. Hope this helps. Thanks.
The issue, as Aaron Golden has pointed out, is that a synchronous request is made from the main thread at load time in order to figure out whether the react packager (remote server running on the same network) is accessible. This can take awhile for reasons beyond my knowledge (if someone can expound on this, I'd be grateful), but apple will crash the app if this takes longer than 19 seconds (approx).

Analysing This Crash Report

I got this crash report, and I "symbolicated" it.
Even after that, I am still unable to understand where does my crash comes from.
The app crashes straight after launch.
Here's my crash report :
Hardware Model: iPhone7,2
Version: 1.6.0.3 (1.6.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2015-04-30 15:50:21.019 +0200
Launch Time: 2015-04-30 15:50:15.833 +0200
OS Version: iOS 8.3 (12F70)
Report Version: 105
Exception Type: EXC_CRASH (SIGSEGV)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 1
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_c.dylib 0x0000000193e056ac strlen + 12
1 App 0x000000010012e1ec -[NSString(CategoryName) hashWithSecretKeyUpdateUser] (HashString.m:70)
2 App 0x00000001000eff04 +[InAppPurchaseHelper generateSHAFromDictionary:registerOrReadOrUpdate:] (InAppPurchaseHelper.m:177)
3 App 0x00000001000ef5b8 +[InAppPurchaseHelper updateUserInfosRegisterProfile:registerPush:] (InAppPurchaseHelper.m:119)
4 App 0x0000000100166574 -[AppDelegate applicationDidBecomeActive:] (AppDelegate.m:218)
5 UIKit 0x00000001869f7474 -[UIApplication _stopDeactivatingForReason:] + 456
6 CoreFoundation 0x0000000181eda2c0 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 16
7 CoreFoundation 0x0000000181eda72c ____CFXNotificationPostToken_block_invoke + 140
8 CoreFoundation 0x0000000181eec278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16
9 CoreFoundation 0x0000000181eeb380 __CFRunLoopDoBlocks + 308
10 CoreFoundation 0x0000000181ee99a4 __CFRunLoopRun + 1752
11 CoreFoundation 0x0000000181e152d0 CFRunLoopRunSpecific + 392
12 GraphicsServices 0x000000018b62b6f8 GSEventRunModal + 164
13 UIKit 0x00000001869dafa8 UIApplicationMain + 1484
14 App 0x0000000100100ea4 main (main.m:16)
15 libdyld.dylib 0x0000000193dd6a04 start + 0
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x0000000193ed4c24 kevent64 + 8
1 libdispatch.dylib 0x0000000193db9e6c _dispatch_mgr_invoke + 272
2 libdispatch.dylib 0x0000000193dab998 _dispatch_mgr_thread + 48
Does this report means that the crash occured in the "hashWithSecretKeyUpdateUser" function call ?
Is there a way to know more about the crash ?
I wasn't able to get my App to crash at this point
It looks like "Segmentation fault"(SIGSEGV) which means your code accessing the memory that doesn't exist or invalid. According to your crash report, it looks like hashWithSecretKeyUpdateUser accessing wrong or invalid memory from "strlen + 12" which I believe string you are passing into hashWithSecretKeyUpdateUser is not exist or fault.

Crash report.. any clue where to look for?

I'm receiving many iOS crash reports that look like copied below... Does anyone have any clue where to look for a resolution? It seems the crash occurs during launch, but it is not clear at all which method is responsible for it. I can also not reproduce it..
Thanks!
Hardware Model: iPhone4,1
Process: XXXXXX [499]
Path: /Users/USER/XXXX.app/XXXX
Identifier: XXXXXXX
Version: 16.1
Code Type: ARM
Parent Process: launchd [1]
Date/Time: 2013-10-26T00:14:55Z
OS Version: iPhone OS 7.0.2 (11A501)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x3a3d41fc
Crashed Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3a3d41fc ___pthread_kill + 8
1 libsystem_c.dylib 0x3a384ffd _abort + 77
2 libc++abi.dylib 0x396b3cd7 abort_message + 75
3 libc++abi.dylib 0x396cc6e5 default_terminate_handler() + 253
4 libobjc.A.dylib 0x39e15921 _objc_terminate() + 193
5 libc++abi.dylib 0x396ca1c7 std::__terminate(void (*)()) + 79
6 libc++abi.dylib 0x396c9d2d ___cxa_increment_exception_refcount + 1
7 libobjc.A.dylib 0x39e157f7 _objc_exception_rethrow + 43
8 CoreFoundation 0x2f970d5d _CFRunLoopRunSpecific + 641
9 CoreFoundation 0x2f970acb _CFRunLoopRunInMode + 107
10 GraphicsServices 0x34691283 _GSEventRunModal + 139
11 UIKit 0x32212a41 _UIApplicationMain + 1137
12 XXXXXXX 0x000829d7 main (main.m:55)
The reason is that a Objective-C exception was thrown, caught, and then re-thrown. The original stacktrace is then lost unless you saved/logged it where you caught it.
Look for any place in your code where you catch Objective-C exceptions, and also look in any third party frameworks you might use.
Of course, first try to reproduce the problem in a debugger, where you set a breakpoint on all exceptions (click the little '+' icon down to the left in the Breakpoint tab in Xcode).

iPad app, will run in debug but adhoc crashes

Here is the crash log
Date/Time: 2011-02-10 21:12:00.478 +0900
OS Version: iPhone OS 4.2.1 (8C148)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x30d7c2d4 __kill + 8
1 libSystem.B.dylib 0x30d7c2c4 kill + 4
2 libSystem.B.dylib 0x30d7c2b6 raise + 10
3 libSystem.B.dylib 0x30d90d72 abort + 50
4 libstdc++.6.dylib 0x34981a20 __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x34a83594 _objc_terminate + 104
6 libstdc++.6.dylib 0x3497fdf2 __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x3497fe46 std::terminate() + 10
8 libstdc++.6.dylib 0x3497ff16 __cxa_throw + 78
9 libobjc.A.dylib 0x34a824c4 objc_exception_throw + 64
10 CoreFoundation 0x3587c1a8 +[NSObject(NSObject) doesNotRecognizeSelector:] + 96
11 CoreFoundation 0x35823aa2 ___forwarding___ + 502
12 CoreFoundation 0x35823858 _CF_forwarding_prep_0 + 40
13 PictureDictionary 0x00005fe4 sgLoadFileImage(char const*, long*) (PictureDictionary.mm:41)
14 PictureDictionary 0x000061b0 CPictureDictionary::LoadPageData() (PictureDictionary.mm:814)
15 PictureDictionary 0x00006d02 CPictureDictionary::Update() (PictureDictionary.mm:505)
16 PictureDictionary 0x00003216 -[ES1Renderer render] (ES1Renderer.mm:63)
The line in my code where it starts to crash (with in stack trash #13 above) is
NSString* pStr = [[NSString alloc]
initWithUTF8String: pFileName];
For some reason it crashes here.
What is odd is that it runs fine in debug mode. But when I make a adhoc build and put it in the iPad through iTunes the above crash occurs.
I have cleaned and rebuilt many times, made sure my profiles and identifiers are correct.
I have no idea why this may be happening. Any insight or suggestions will help.
Thanks.
Sorry I'm no guru but maybe this will help a little.
This type of crash occurs when Cocoa cannot find the method you are invoking at runtime.
Normally you would receive a warning during compilation.
That said, it seems to be complaining that it cannot find an objective-C selector (method). However, sgLoadFileImage looks to me to be a C function.
For sure, something is different between your debug and release builds. Either the code is different, or the parameters supplied to the methods and functions.

iPhone App Rejected by Apple with crash report - can not reproduce

I am totally at a loss on this crash report. I have several fairly complicated apps already in the store and recently submitted an update to one of them. I promptly received the response it had been rejected for crashing on startup. They are using exactly the same SDK version as me, 3.1.2. After symbolicating the stack trace, this is what was crashing:
Process: MyAppName [60]
Path: /var/mobile/Applications/0EC19245-D3A4-47D0-94D9-XXXXXXXXXX/MyAppName.app/MyAppName
Identifier: MyAppName
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2010-01-19 15:43:46.804 -0800
OS Version: iPhone OS 3.1.2 (7D11)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
and this is the pertinent stack trace.
Thread 0 Crashed:
0 libSystem.B.dylib 0x0007e9ac __kill + 8
1 libSystem.B.dylib 0x0007e99c kill + 4
2 libSystem.B.dylib 0x0007e98e raise + 10
3 libSystem.B.dylib 0x0009363a abort + 34
4 libstdc++.6.dylib 0x000453b0 __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x00005858 _objc_terminate + 104
6 libstdc++.6.dylib 0x00043776 __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x000437ca std::terminate() + 10
8 libstdc++.6.dylib 0x00043896 __cxa_throw + 74
9 libobjc.A.dylib 0x00004714 objc_exception_throw + 64
10 Foundation 0x000013c2 __NSThreadPerformPerform + 570
11 CoreFoundation 0x00056a96 CFRunLoopRunSpecific + 1834
12 CoreFoundation 0x00056356 CFRunLoopRunInMode + 42
13 GraphicsServices 0x00003cb8 GSEventRunModal + 108
14 GraphicsServices 0x00003d64 GSEventRun + 56
15 UIKit 0x00002768 -[UIApplication _run] + 384
16 UIKit 0x0000146c UIApplicationMain + 688
17 MyAppName 0x0000ed6a main (main.m:13)
18 MyAppName 0x000028e4 start + 44
To me that stacktrace is near useless, it just says a component crashed when we started your app yet I can not reproduce it on a similar system (the only difference being they are running Snow Leopard and I am just running Leopard).
Any suggestions as to what I could next? Thanks.
If you are running Snow Leopard, turn on the Static Analyzer in your project.
Turn on NSZombieEnabled
http://www.frogameleon.com/blog/last-night-an-iphone-zombie-nszombieenabled-saved-my-life
Review the other Debugging docs and use the tools Apple provides.
http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/130-Debugging_Applications/debugging_applications.html
Actually it doesn't say a component crashed when you started the app. The crash may have happened at any point.
What it does say though, is that it crashed in NSThreadPerform, which seems like you were trying to call performSelector on either an object that no longer existed, or possibly against an object that did not have the method you were trying to invoke.
So I'd look for anywhere you use performSelector on the main thread, and try and think from there how the target could be invalid.

Resources