Apparently my apps crashes when using the live server. I'm downloading XML when a user changed the mapregion. The server returns data for the boundingbox and my apps shows the annotation. However when a place has a url variable set my app just crashes. It doesnt even break on a exception breakpoint but just goes straight to main.m.
My device crash log looks like this:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3b06f1fc __pthread_kill + 8
1 libsystem_pthread.dylib 0x3b0d6a4e pthread_kill + 54
2 libsystem_c.dylib 0x3b020028 abort + 72
3 libsystem_malloc.dylib 0x3b09d758 szone_error + 312
4 libsystem_malloc.dylib 0x3b09da1a free_tiny_botch + 62
5 CoreFoundation 0x30692fd6 CFRelease + 890
6 APPName 0x0011ef04 -[MyPlaceClass dealloc] (MyPlaceClass.mm:650)
7 APPName 0x0011f684 -[MyTextPlace dealloc] (MyTextPlace.m:46)
8 libobjc.A.dylib 0x3aacab06 objc_object::sidetable_release(bool) + 170
9 CoreFoundation 0x30692e88 CFRelease + 556
10 CoreFoundation 0x3069e3b4 -[__NSArrayM dealloc] + 156
11 libobjc.A.dylib 0x3aacab06 objc_object::sidetable_release(bool) + 170
12 libobjc.A.dylib 0x3aabc01e (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 354
13 CoreFoundation 0x306961c4 _CFAutoreleasePoolPop + 12
14 UIKit 0x32edf80c _wrapRunLoopWithAutoreleasePoolHandler + 32
15
I checked (MyPlaceClass.mm:650) and (MyTextPlace.m:46). And that just looks like this:
MyPlaceClass.mm on line 650
- (void)dealloc {
.....
[placeURL release]; // <- This is line 650
[super dealloc];
}
MyTextPlace.m on line 46
- (void)dealloc {
[textContent release]; // <- This is line 46
[super dealloc];
}
Does somebody know whats causing my error and crash on my device? I find it really hard te debug because my exception breakpoints just dont work.
placeURL was already being released.
Related
Hi i have a Problem with this Library:
LTSupportAutomotive
I´m a swift programmer so not really good in objective c.
how to fix this race condition?
I hope someone can help me.
'*** -[__NSArrayM insertObject:atIndex:]: index 1 beyond bounds for empty array'
-(void)asyncEnqueueInternalCommand:(LTOBD2AdapterInternalCommand*)internalCommand
{
#synchronized(self) {
[_commandQueue addObject:internalCommand];
}
}
Source code:
https://github.com/mickeyl/LTSupportAutomotive/blob/f51b962421f211ee6af5c733f79190117d7cac5e/LTSupportAutomotive/LTOBD2Adapter.m
UPDATE 1:
Created a branch with the first fixes:
https://github.com/Skyb0rg/LTSupportAutomotive/tree/BugfixMemoryManagement
After adding additional commandQueue i got new errors:
in LTBTLEWriteCharacteristicStream.m
-(void)characteristicDidWriteValue
{
[self.delegate stream:self handleEvent:NSStreamEventHasSpaceAvailable];
}
this function is crashing with:
Selector name found in current argument registers: delegate
Thread 6 Crashed:
0 libobjc.A.dylib 0x00000001bcc19430 objc_retain + 16
1 LTSupportAutomotive 0x00000001093c2a34 -[LTBTLEWriteCharacteristicStream characteristicDidWriteValue] (LTBTLEWriteCharacteristicStream.m:39)
2 LTSupportAutomotive 0x00000001093c2714 -[LTBTLESerialTransporter peripheral:didWriteValueForCharacteristic:error:] (LTBTLESerialTransporter.m:311)
3 CoreBluetooth 0x00000001c35e6ce0 -[CBPeripheral handleAttributeEvent:args:attributeSelector:delegateSelector:delegateFlag:] + 236
4 CoreBluetooth 0x00000001c35e6e40 -[CBPeripheral handleCharacteristicEvent:characteristicSelector:delegateSelector:delegateFlag:] + 128
5 CoreBluetooth 0x00000001c35e24f0 -[CBPeripheral handleMsg:args:] + 352
6 CoreBluetooth 0x00000001c35dcbfc -[CBCentralManager handleMsg:args:] + 200
7 CoreBluetooth 0x00000001c35eb770 __30-[CBXpcConnection _handleMsg:]_block_invoke + 56
8 libdispatch.dylib 0x00000001bd4696c8 _dispatch_call_block_and_release + 20
9 libdispatch.dylib 0x00000001bd46a484 _dispatch_client_callout + 12
10 libdispatch.dylib 0x00000001bd411bd0 _dispatch_lane_serial_drain$VARIANT$mp + 588
11 libdispatch.dylib 0x00000001bd41274c _dispatch_lane_invoke$VARIANT$mp + 480
12 libdispatch.dylib 0x00000001bd411a9c _dispatch_lane_serial_drain$VARIANT$mp + 280
13 libdispatch.dylib 0x00000001bd412718 _dispatch_lane_invoke$VARIANT$mp + 428
14 libdispatch.dylib 0x00000001bd41aeb8 _dispatch_workloop_worker_thread + 596
15 libsystem_pthread.dylib 0x00000001bd64d0dc _pthread_wqthread + 308
16 libsystem_pthread.dylib 0x00000001bd64fcec start_wqthread + 0
and another crash in: LTBTLEReadCharacteristicStream.m
-(void)characteristicDidUpdateValue
{
NSData* value = _characteristic.value;
[_buffer appendData:value];
[self.delegate stream:self handleEvent:NSStreamEventHasBytesAvailable];
}
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OS_dispatch_data stream:handleEvent:]: unrecognized selector sent to instance 0x281be1b90'
Thread 9 Crashed:
0 libsystem_kernel.dylib 0x00000001bd5c7104 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001bd643020 pthread_kill$VARIANT$mp + 376
2 libsystem_c.dylib 0x00000001bd51ed78 abort + 136
3 VW-R-CLUB Member APP 0x00000001045603ac uncaught_exception_handler + 68
4 CoreFoundation 0x00000001bda321e0 __handleUncaughtException + 688
5 libobjc.A.dylib 0x00000001bcc01e4c _objc_terminate() + 108
6 VW-R-CLUB Member APP 0x0000000104555c4c BITCrashUncaughtCXXTerminateHandler() (BITCrashCXXExceptionHandler.mm:183)
7 libc++abi.dylib 0x00000001bcbf50fc std::__terminate(void (*)()) + 12
8 libc++abi.dylib 0x00000001bcbf5188 std::terminate() + 80
9 libdispatch.dylib 0x00000001bd46a498 _dispatch_client_callout + 32
10 libdispatch.dylib 0x00000001bd411bd0 _dispatch_lane_serial_drain$VARIANT$mp + 588
11 libdispatch.dylib 0x00000001bd41274c _dispatch_lane_invoke$VARIANT$mp + 480
12 libdispatch.dylib 0x00000001bd411a9c _dispatch_lane_serial_drain$VARIANT$mp + 280
13 libdispatch.dylib 0x00000001bd412718 _dispatch_lane_invoke$VARIANT$mp + 428
14 libdispatch.dylib 0x00000001bd41aeb8 _dispatch_workloop_worker_thread + 596
15 libsystem_pthread.dylib 0x00000001bd64d0dc _pthread_wqthread + 308
16 libsystem_pthread.dylib 0x00000001bd64fcec start_wqthread + 0
First, the code you show is not the one to be found in github. Do you synchronize all usages of _commandQueue, or only this one? If only this one, why aren't the others synchronized?
Then, in github I find multiple usages of _commandQueue, some of them in methods that are named async..., but also some not async, like cancelPendingCommands or responseCompleted. You need to find out what is the intention of async in a method name, and why methods like cancelPendingCommands is not somehow async.
Update
So the main idea seems to protect all _commandQueue accesses inside the serial _dispatchQueue. This is already the case in the async... methods: They are called from within that queue:
dispatch_async( _dispatchQueue, ^{
[self asyncEnqueueInternalCommand:internalCommand];
});
So you need to ensure that every access to _commandQueue is enqueued in this queue, e.g. change cancelPendingCommands to something like
-(void)cancelPendingCommands
{
dispatch_async( _dispatchQueue, ^{
// This cancels all but the first command in order to prevent sending a new command while
// the response to an active command is still pending. OBD2 adapters usually can't cope with
// that and emit a 'STOPPED' response in that case.
if ( _hasPendingAnswer )
{
NSRange allButTheFirst = NSMakeRange( 1, _commandQueue.count - 1 );
[_commandQueue removeObjectsInRange:allButTheFirst];
}
else
{
[_commandQueue removeAllObjects];
}
});
}
(or create a dedicated asyncCancelPendingCommands function, that will be called from cancelPendingCommands from inside a dispatch block. And so on.
P.S. If you need synchronous execution, you could also use dispatch_sync instead of dispatch_async, but then you have to ensure that you do not create deadlocks.
I have a strage crash scenario to crash the app!
When you do a fresh install by running the app from Xcode; the application will run perfectly.
But I installed by current app from app store, then run the application, now everything is perfect till you click on home button, the application will crash at that moment! What's the problem? And How could I solve it?
UPDATED (This is the log):
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x6f687370
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 ??? 0x6f687370 0 + 1869116272
1 CoreFoundation 0x291ad93c _CFXNotificationPost + 1784
2 Foundation 0x29edd9b8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
3 UIKit 0x2c99b7ae -[UIApplication _handleApplicationDectivationWithScene:shouldForceExit:transitionContext:completion:] + 882
4 UIKit 0x2c9a29f0 __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 76
5 UIKit 0x2c9a299c -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 360
6 UIKit 0x2c997c82 -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 478
7 FrontBoardServices 0x2f9a21f8 __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke_2 + 40
8 FrontBoardServices 0x2f9b10e8 __31-[FBSSerialQueue performAsync:]_block_invoke + 12
9 CoreFoundation 0x2925f5b4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
10 CoreFoundation 0x2925e878 __CFRunLoopDoBlocks + 216
11 CoreFoundation 0x2925d3b2 __CFRunLoopRun + 1714
12 CoreFoundation 0x291ab620 CFRunLoopRunSpecific + 476
13 CoreFoundation 0x291ab432 CFRunLoopRunInMode + 106
14 GraphicsServices 0x305310a8 GSEventRunModal + 136
15 UIKit 0x2c796358 UIApplicationMain + 1440
16 MyNiceTestApp 0x000cae9e 0xc4000 + 28318
17 libdyld.dylib 0x371bfaae start + 2
Since there is not source code to look at my guess would be you have registered for
an observer for NSNotificationCenter and you have not removed the observer before the
application terminates.
This will cause you problems if an NSNotification was delivered to a deallocated
listener.
It appears one of UIApplicationDidEnterBackgroundNotification listeners is deallocated without unregistering from observing UIApplicationDidEnterBackgroundNotification notification
I can't reproduce some bug that happens sometimes. This is a report:
Exception Type: EXC_CRASH (SIGSEGV)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 1
Thread 0:
0 libobjc.A.dylib 0x3b4b97fa objc_release + 10
1 MyApp 0x00173610 -[AFHTTPRequestOperation error] (AFHTTPRequestOperation.m:136)
2 MyApp 0x001460ea -[RKObjectRequestOperationLogger HTTPOperationDidFinish:] (RKObjectRequestOperation.m:209)
3 CoreFoundation 0x31121e6e __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 10
4 CoreFoundation 0x31095aac _CFXNotificationPost + 1716
5 Foundation 0x31a7bec0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
6 Foundation 0x31a807c2 -[NSNotificationCenter postNotificationName:object:] + 26
7 MyApp 0x0017e44e __34-[AFURLConnectionOperation finish]_block_invoke (AFURLConnectionOperation.m:558)
8 libdispatch.dylib 0x3b9a10c0 _dispatch_call_block_and_release + 8
9 libdispatch.dylib 0x3b9a10ac _dispatch_client_callout + 20
10 libdispatch.dylib 0x3b9a39a4 _dispatch_main_queue_callback_4CF + 264
11 CoreFoundation 0x3112a5ac __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
12 CoreFoundation 0x31128e78 __CFRunLoopRun + 1304
13 CoreFoundation 0x3109346c CFRunLoopRunSpecific + 520
14 CoreFoundation 0x3109324e CFRunLoopRunInMode + 102
15 GraphicsServices 0x35dcd2e6 GSEventRunModal + 134
16 UIKit 0x33948840 UIApplicationMain + 1132
17 MyApp 0x00014d54 main (main.m:16)
18 libdyld.dylib 0x3b9b5ab4 start + 0
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x3ba59838 kevent64 + 24
1 libdispatch.dylib 0x3b9a80d0 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x3b9a261e _dispatch_mgr_thread + 34
What can i understand from such a record? Who can be a culprit?
AFHTTPRequestOperation.m:136 don't looks that can to cause the crash
135: - (NSError *)error {
136: if (!self.HTTPError && self.response) {
137: if (![self hasAcceptableStatusCode] || ![self hasAcceptableContentType]) {
so from where objc_release can come? Does objc_release means that ARC tries to release something from memory? In what period of time (place in code) it can be happened?
providing code of AFURLConnectionOperation.m :
- (void)finish {
self.state = AFOperationFinishedState;
dispatch_async(dispatch_get_main_queue(), ^{
558: [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
});
}
Try using the weakSelf code pattern with the block. A weak rather than a strong reference within the block will avoid the release, hopefully.
See the answers here:
What is the proper way to avoid Retain Cycle while using blocks
I actually like the 2nd most popular answer for async. And I really really like it because you have this method called "finish" -- if you happen to make self go away simultaneous with the block being executed, perhaps you get this error.
Hope that works for you.
I'm using Worklight 6.0.0.1 + 9-26 iFix.
A few minutes after a successful call to do a Worklight Connect, our app crashes with this error which looks like it may involve a JSON parsing problem from Worklight:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFConstantString substringWithRange:]: Range {2147483647, 1} out of bounds; string length 0'
*** First throw call stack:
(
0 CoreFoundation 0x021615e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01ee48b6 objc_exception_throw + 44
2 CoreFoundation 0x021613bb +[NSException raise:format:] + 139
3 CoreFoundation 0x0213a5e8 -[__NSCFString substringWithRange:] + 136
4 MyApp 0x00036546 +[WLUtils parseJSONString:] + 230
5 MyApp 0x00032447 -[WLRequest requestFinished:] + 167
6 libobjc.A.dylib 0x01ef681f -[NSObject performSelector:withObject:] + 70
7 MyApp 0x00058a1b -[ASIHTTPRequest reportFinished] + 171
8 libobjc.A.dylib 0x01ef681f -[NSObject performSelector:withObject:] + 70
9 Foundation 0x01b39c18 __NSThreadPerformPerform + 285
10 CoreFoundation 0x020ea8af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
11 CoreFoundation 0x020ea23b __CFRunLoopDoSources0 + 235
12 CoreFoundation 0x0210730e __CFRunLoopRun + 910
13 CoreFoundation 0x02106b33 CFRunLoopRunSpecific + 467
14 CoreFoundation 0x0210694b CFRunLoopRunInMode + 123
15 GraphicsServices 0x0337f9d7 GSEventRunModal + 192
16 GraphicsServices 0x0337f7fe GSEventRun + 104
17 UIKit 0x00c5794b UIApplicationMain + 1225
18 MyApp 0x0000b9ad main + 141
19 libdyld.dylib 0x02abd725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
We're doing the connect like this and getting a success response:
MyConnectListener *connectListener = [[MyConnectListener alloc] init];
[[WLClient sharedInstance] wlConnectWithDelegate:connectListener];
MyConnectListener implements WLDelegate
MyConnectListener.m:
-(void)onSuccess:(WLResponse *)response
{
NSLog(#"Connection Success: %#", response);
}
-(void)onFailure:(WLFailResponse *)response
{
NSLog(#"Connection failure: %#", response);
}
Any idea how to solve this?
This has been logged as a defect and will be fixed in a future release. The current workaround is to disable the heartbeat functionality using the following syntax:
[[WLClient sharedInstance] setHeartBeatInterval:-1];
Thread 12 Crashed:
0 libsystem_kernel.dylib 0x3076da1c __pthread_kill + 8
1 libsystem_c.dylib 0x35c8a3b4 pthread_kill + 52
2 libsystem_c.dylib 0x35c82bf8 abort + 72
3 libstdc++.6.dylib 0x33f61a64 __gnu_cxx::__verbose_terminate_handler() + 376
4 libobjc.A.dylib 0x360f506c _objc_terminate + 104
5 libstdc++.6.dylib 0x33f5fe36 __cxxabiv1::__terminate(void (*)()) + 46
6 libstdc++.6.dylib 0x33f5fe8a std::terminate() + 10
7 libstdc++.6.dylib 0x33f5ff5a __cxa_throw + 78
8 libobjc.A.dylib 0x360f3c84 objc_exception_throw + 64
9 Foundation 0x31af8dea _NSOutOfMemoryErrorHandler + 38
10 CoreFoundation 0x31e91496 __CFStringHandleOutOfMemory + 22
11 CoreFoundation 0x31e951ea __CFStringChangeSizeMultiple + 506
12 CoreFoundation 0x31e982c0 __CFStringCheckAndReplace + 148
13 Foundation 0x31a81228 -[NSCFString appendString:] + 28
14 MyApp 0x00016a86 -[XMLParser parser:foundCharacters:] (XMLParser.m:109)
Crashed with SIGABRT on device.
XMLParser code snippet :
- (void)parser:(XMLParser *)parser foundCharacters:(NSString *)string
{
if(!currentString)
{
currentString = [[NSMutableString alloc] init];
}
[currentString appendString:string]; // Line 109 that crashed
}
Why does it crash there is it appending nil string ? or accessing protected memory
The _NSOutOfMemoryErrorHandler makes it rather clear - you're running out of memory. Check for parts that are too memory-intensive for the device using Instruments and memory leaks etc.