SIGKill Without warning or stack trace with NSLogv - iphone

I know this is a somewhat vague question, but during debug execution, the app I'm working on dies without any stacktrace or warning and with simply this message in the debug console:
Program received signal: “SIGKILL”.
I have NSZombieEnabled, NSDebugEnabled, MallocStackLoggingNotCompact and MallocStackLogging all set within XCode.
I've run Instruments to check for memory leaks with none reported.
The last place I can step into with the debugger after it reports that the "GDB: Interrupted" is this piece of code where NSLogv is invoked:
+ (void)print:(NSString *)format, ...
{
va_list args;
va_start(args, format);
// Doesn't seem to go past this line
NSLogv(format, args);
va_end(args);
}
But this method is invoked many a times throughout the app and no problem in any where until at some point after I've used the app long enough.
The stack shown through the debugger thereafter is:
#0 0x02592e07 in ___forwarding___
#1 0x02592cd2 in __forwarding_prep_0___
#2 0x000ce57f in _NSDescriptionWithLocaleFunc
#3 0x0260b00d in __CFStringAppendFormatCore
#4 0x02552f87 in _CFStringCreateWithFormatAndArgumentsAux
#5 0x025da36e in _CFLogvEx
#6 0x0014beb5 in NSLogv
Upon re-testing over and over again, the SIGKILL consistently happens with the call to NSLogv and no where else.
What else can I turn or set to figure out why the debugger is terminating the instance of the app?

Check the format string and the arguments supplied are the correct type, for instance with a format string of #"%f" and argument of #"hello", this would crash....

Related

Xcode 5.1.1 Thread 1: signal SIGABRT

When i run my app, after a while it stops working and say thread 1: signal SIGABRT. it says it on this code:
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
It says it on this line:
int retVal = UIApplicationMain(argc, argv, nil, nil);
SIGABRT means an exception was triggered. The console log will print the exact exception message, and you need to look at that (post it here).
The problem is probably in your UIApplicationMain method
To Expand on user3109992 answer a SIGABRT usually means an exception was thrown. Generally you want to enable a global exception breakpoint so that your program will be stopped on the line of code that generated the exception rather than just crashing on main so that you can gain some meaningful information as to what happened.
To set a global breakpoint use the breakpoint navigator (looks like a diamond) on your left bar (or command 7). On the lower left click the + icon and choose "Exception Breakpoint". Now your program will crash at the point the exception is thrown. However this still won't print the actual exception to the console.
To print the exception to the console when the crash occurs select the stack frame that says something like "objc exception throw", it will be at the top of the left window. If your running on simulator type: po $eax and in general the exception will be printed to the console. Note that sometimes the register where the exception is located is different if your on a device or the 64 bit simulator so you can type: "register read" and it will give you a list of registers. The one at the top holds the exception so you can type: "po " to see it. You can have the exception print automatically when your program crashes at main by setting "Log Exceptions" in the scheme (product -> scheme-> edit scheme), accessed by choosing the diagnostic tab in the edit scheme window. However if you have a breakpoint set then your breakpoint will stop the program before the debugger gets a chance. I prefer the breakpoint approach because I usually want to poke around to understand more of whats going on when the app crashed.
I'd suggest you go back and watch some of the debugging and LLDB videos from the past couple of WWDC's as it sounds like you don't have a whole lot of experience with the debugger. The beginning videos have a ton of useful information.

My phone app is suddenly crashing because of the main.m file

Suddenly when I try to run my app it immediately goes to the main.m file and shows me this SIGABRT error which I'm going to assume is Signal abort. I just can't figure out why that is happening. And I'm not sure what I am looking at in my debugging area. Please help!
#import <UIKit/UIKit.h>
#import "Mct2AppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([Mct2AppDelegate
class]));
}
}
Debugger Output:
Attaching to process 8004.
Pending breakpoint 1 - ""main.m":17" resolved
Couldn't register com.ebonybutler.Mct2 with the bootstrap server. Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.Current language: auto; currently objective-c
Second Debugger Output since restart:
2012-02-29 16:46:45.561 Mct2[319:f803] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "Menu" nib but the view outlet was not set.'
* First throw call stack:
(0x13bb052 0x154cd0a 0x1363a78 0x13639e9 0xd7f0d 0xd83a9 0x2415e2 0xd85cb 0x25e4 0x13bcec9 0x155c2 0x1555a 0xbab76 0xbb03f 0xba2fe 0x3aa30 0x3ac56 0x21384 0x14aa9 0x12a5fa9 0x138f1c5 0x12f4022 0x12f290a 0x12f1db4 0x12f1ccb 0x12a4879 0x12a493e 0x12a9b 0x2032 0x1fa5)
terminate called throwing an exceptionCurrent language: auto; currently objective-c
Simple fix, if you're using iOS simulator, just close it down and rerun the project
This is Happens because your application getting terminate.
Try the following things in the below order:
Make sure all only one program is being debugged in XCode, close other running instances.
shut down your system and restart it before doing third steps.
Restart XCode, most of time this is take care of the issue.
If you are running this on the device and is still not working restart the device and try again.
It Really Work.

incorrect checksum for freed object. Extremely strange crash on app

I've been working on an app for some time now.. Up until now i've been running it whilst the debugger has been attached and it was working well (because NSZombies was enabled)...
I recently noticed that when pushing to a new view controller the app would crash. I figured it would be a simple fix but so far its not looking that way.
The app works by doing the following (this method has worked previously)...
User Selects View
RootViewController pushed to tableViewController
User Selects item
ViewController initialised and configured
Navigation Controller pushes to new ViewController
Now if I configure my scheme to enable NSZombies, then this works fine.. my new view loads and vola, it works.
However.. if i don't the app crashes!
In my console window, I get the following error:
2012-01-17 19:51:14.599 DrivingInstructor[61946:17003] -[PhotoViewController loadView]
2012-01-17 19:51:14.654 DrivingInstructor[61946:17003] -[PhotoViewController viewWillAppear:]
DrivingInstructor(61946,0xac6ad2c0) malloc: *** error for object 0x92b0e14: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
So i set the malloc_error_break to see whats happening... doesn't make a difference, I still get the above error (note the first two messages show that my new ViewController is initialising)
If I run a backtrace after the crash.. here is my output:
#0 0x956a9c97 in malloc_error_break ()
#1 0x9566b4ce in szone_error ()
#2 0x9566b54e in free_list_checksum_botch ()
#3 0x9566b63f in tiny_free_list_remove_ptr ()
#4 0x956702b1 in szone_free ()
#5 0x01f30a98 in __CFAllocatorSystemDeallocate ()
#6 0x01f2978a in CFAllocatorDeallocate ()
#7 0x01f30960 in CFRelease ()
#8 0x01fe6b4f in __CFDictionaryStandardReleaseKey ()
#9 0x01f474df in __CFBasicHashDrain ()
#10 0x01f304e3 in CFRelease ()
#11 0x02011e94 in -[__NSArrayM dealloc] ()
#12 0x021c8e4d in _objc_rootRelease ()
#13 0x021c8e10 in objc_release ()
#14 0x021c9c60 in (anonymous namespace)::AutoreleasePoolPage::pop ()
#15 0x01f58ed8 in _CFAutoreleasePoolPop ()
#16 0x015f08ce in __NSFireDelayedPerform ()
#17 0x01ff8966 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#18 0x01ff8407 in __CFRunLoopDoTimer ()
#19 0x01f5b7c0 in __CFRunLoopRun ()
#20 0x01f5adb4 in CFRunLoopRunSpecific ()
#21 0x01f5accb in CFRunLoopRunInMode ()
#22 0x023e2879 in GSEventRunModal ()
#23 0x023e293e in GSEventRun ()
#24 0x00cd8a9b in UIApplicationMain ()
#25 0x00002149 in main (argc=1, argv=0xbffff5d4) at main.m:14
I should also point out... I originally thought this was being caused by me running a background thread what resizes images for me while the ui loads so there is no freezing up as my first crash log suggested it was crashing on a certain line in my image processing class but after not being able to sort that and commenting out the function what resizes the images (runs on background thread).. Now the app is crashing without me even calling that thread!
I don't know what has happened to is as my initial crash logs where telling me it was an issue using UIGraphics on a background thread while the crash was happening...
Now it just crashes :S
Here is my crash log below:
(pastebin as i go over 3k character limit)
http://pastebin.com/dGF7QdeH
I would share the code to the app where this issue is occurring but I don't know where it's happening so I can't show you :S
From what I can see, the viewWillAppear: function is called so I can setup my view, but it crashes just before i actually push to it but there is nothing unusual in the setup of the view as the only code i have altered since the last working version is setting up of my view (what runs fine)
If anybody can help me with this I will be VERY grateful... I've been stressing over this all day and posting here is my last resort (before I go to developer.apple.com)
Thanks for reading, Please let me know if you need more info.
Liam
First of all, find out what object is 0x92b0e14. (or whatever address shows up in your debugger.) Once you know what object it is, then put breakpoints everywhere you release it, and put a breakpoint where you get the error. When you hit the release before you hit the error, then you see what the problem is.
It might be that you never retain this object, which could give the same results if it is changed after being autoreleased. In this case, implement a retain/release scheme that keeps this object alive until you're done with it.
You hosed something on the main thread, and the background thread used to trip on it first.
When all else fails, you can use binary search to find the problem. Make a new #define like SEARCH_BUG=1 then use #ifdef SEARCH_BUG to comment out vast areas of code. Leaving Zombies on and enabling scribbling, and everything else would also likely find the bug faster than without it.
This is an iPhone app, run it in the simulator, and on hardware - iPad - etc perhaps the problem will manifest earlier on real hardware or in a simulator.
That stack sure looks like something is being over-released. (Which is less likely if you really did have zombie detection on.)
I don't know if this will help, but the few times I encountered a malloc error, two instances of the same view controller class unintentionally exist in my view controller hierarchy. Try putting NSLog(#"init: %#", self); in your view controllers' init() and NSLog(#"dealloc: %#", self); in their dealloc(), then compare the class names and instance addresses.
I found the function free_list_checksum_botch() on Apple open source.
https://opensource.apple.com/source/Libc/Libc-825.26/gen/magazine_malloc.c
It try to put error log "incorrect checksum for freed object - object was probably modified after being freed."

Zend_Auth and Zend_Namespace Session Error

I'm developing an application, everything works fine but sometimes i get the following error:
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()' in /usr/share/php/libzend-framework-php/Zend/Session.php:462 Stack trace: #0 /usr/share/php/libzend-framework-php/Zend/Session/Namespace.php(143): Zend_Session::start(true) #1 /var/vhosts/rmanager.vsnetwork.net/application/views/helpers/GetProjetoNome.php(7): Zend_Session_Namespace->__construct('rmanager') #2 [internal function]: Zend_View_Helper_GetProjetoNome->GetProjetoNome() #3 /usr/share/php/libzend-framework-php/Zend/View/Abstract.php(342): call_user_func_array(Array, Array) #4 /var/vhosts/rmanager.vsnetwork.net/application/layouts/scripts/layout.phtml(73): Zend_View_Abstract->__call('GetProjetoNome', Array) #5 /var/vhosts/rmanager.vsnetwork.net/application/layouts/scripts/layout.phtml(73): Zend_View->GetProjetoNome() #6 /usr/share/php/libzend-framework-php/Zend/View.php(108): include('/var/vhosts/rma...') #7 /usr/share/php/libzend-framework-php/Zend/View/Abstract.php(880) in /usr/share/php/libzend-framework-php/Zend/Session.php on line 462
If i refresh the page, it works.
Sometimes it returns me the error while i send post to the same page
I'm using Zend_Auth and Zend_Acl inside a plugin and Zend_Namespace in various places of my application.
Does anyone has idea why it is happing?
Thanks
It's kinda hard to help you with so little information, but as far as i read ealier this week when i play with session_namespace, you have to be very careful with it.
This paragraph has been very helpful for me
Don't ever start the session explicitly. Just use it automatically. I also use Zend_Auth and Zend_Sesison_Namespace many times but that error never comes.

NSUserDefaults:setObject crash

I trying to save app state on processing event applicationWillTerminate. But NSUserDefaults:setObject crashes in 30% cases if UIAlertView with UITextField present on screen. Call stack looks like
[NSUserDefaults setObject]
[NSNotificationCenter postNotificationName]
_CFXNotificationPostNotification
__CFXNotificationPost
_nsnote_callback
[UIKeyboardImpl defaultsDidChange]
[UIKeyboardImpl takeTextInputTraitsFrom]
[NSObjectCopy]
[UITextInputTraits copyWithZone]
[UITextInputTraits takeTraitsFrom]
[UITextInputTraits setInsertionPointColor]
objc_setProperty
objc_msgSend
Then CBR: Program received signal "EXC_BAD_ACCESS". How I can fix it? Thanks.
I am not as proficient in Objective-C but I'd think that you try to store an object that is actually null or an otherwise bad pointer. To investigate that more, you can either plaster the relevant parts with log messages or step through with the debugger.