Edit AllPages

When a Cocoa or other C-based program on Mac OS X crashes, you can receive one of a number of signals, such as “SIGBUS” or “SIGSEGV”. A signal is like a software interrupt. The OS sends your program a signal, and you can register handlers to execute when that signal is sent (except for SIGKILL, which you can’t catch) Below is a list of explanations of these signals, along with common causes. Much of this information was taken from the man page for signal(3), but only signals likely to occur in the event of halted program execution are listed.

*Error # - Code - Signal Definition - Possible Causes *1. SIGHUP - terminal line hangup - this gets sent when your shell’s terminal goes away (like the telephone line hung up, which is where HUP comes from). This signal is also used by convention to tell daemons to reload their configuration files. This works because daemons don’t have controlling terminals, so a HUP signal won’t get sent to them under normal circumstances *2. SIGINT - interrupt program - Control-C was pressed *3. SIGQUIT - quit program - Not technically a crash (can be sent by typing control-) *4. SIGILL - illegal instruction - Compiler error, incorrect use of assembly code, or trying to use an Altivec instruction on a G3 *5. SIGTRAP - trace trap - The code reached a breakpoint *6. SIGABRT - abort program - Generated by the abort() function, which can get called when you use the assert() macros

*Forgetting to removeObserver from the NSNotificationCenter and then releasing that object that needs removed first can cause this signal (sometimes a SIGBUS). One hint you get from PB’s debugger is the line “_CFNotificationCenterPostLocalNotification”.

*8. SIGFPE - floating-point exception - Incorrect use of Altivec code *9. SIGKILL - terminate process - Your process was deliberately terminated *10. SIGBUS - bus error - Incorrect memory access (generally due to incorrect use of retain and release) *11. SIGSEGV - segmentation violation - Use of a pointer that has not been initialized or points to an object that no longer exists (ie: forgot to retain); see also TerminateExplicitListWithNil *12. SIGSYS - non-existent system call invoked - Attempt to call a function not in libkern while programming in the kernel *13. SIGPIPE - write on a pipe with no reader - Errors in a process you are interacting with *14. SIGALRM - real-time timer expired - You can set a timer, which just means that this signal will get sent to your program at a point in time in the future *15. SIGTERM - software termination signal - Your process was deliberately terminated *17. SIGSTOP - stop - Another process has suspended yours *18. SIGTSTP - stop signal from keyboard - Control-Z was pressed *19. SIGCONT - continue *24. SIGXCPU - cpu time limit exceeded - Unless you’re time-sharing on an XServe, this is extremely unlikely, but self-explanatory. You’ll need to have quotas enabled *25. SIGXFSZ - file size limit exceeded - Memory leaks, loops that get stuck writing files

Anybody want to help with common causes for the ? ones? Segfaults and SIGABRT are especially common in Cocoa.

NSLog cause the majority of my segfaults. Two especially common cases: NSLog(“@array”) and NSLog(@”Array: %@”, [array count]).

I really wish there were a good NSLog lint to help catch these.


The first should generate a warning. Fixing all warnings is a Good Thing.

Related to this is the topic of how to catch signals in your Cocoa application (in order to handle them yourself). I provide some sample code for this in a project that can also be used to play around with the various signals in order to understand them better:


Pour devenir figurant sur maintiennent numéro, vous aurez compte opérateur d’identification (code RIO ) [ numéro rio]. Vous obtiendrez pouvez obtenir pour totalement gratuit par téléphonant expression du serveur ou du service à la clientèle support clients votre actuel entreprise [ rio bouygues] . Vous ne mai get un SMS avec vos . Avec du [ code rio orange], alors vous êtes capable d’ sur le offre de de en fruits .