Could you please tell me what could possibly cause a SIGABRT fault in C++?
-
2Good point!!:)I tried looking up it says its a signal that is sent to abort the process from compiler to the system, but my compiler does not say which portion is causing this unusual behavior, To narrow down on this, I asked for possible reasons.My code is 500 lines long. – user1444426 Jun 22 '12 at 17:23
-
@user1444426 - Compile it in debug mode (-g with g++), use dbx and it will find the problem. – Ed Heal Jun 22 '12 at 17:26
-
1@Ecatmur, the Wikipedia page isn't really all that helpful. All it says is that `abort` raises that signal, but it doesn't go beyond that. I get `SIGABRT` signals in my programs sometimes, but I've *never* directly called `abort`. – Rob Kennedy Jun 22 '12 at 17:29
-
To some people up voting wiki comment,first go to that link read /at least glance and then up vote.Makes people get the wrong impression. – user1444426 Jun 22 '12 at 17:56
-
@RobKennedy if I'm reading the same Wikipedia page, it also mentions assertions and correctly points out that the cause can be an internal error in library code. – ecatmur Jun 24 '12 at 22:34
3 Answers
Per Wikipedia,
SIGABRT
is sent by the process to itself when it calls theabort
libc function, defined instdlib.h
. TheSIGABRT
signal can be caught, but it cannot be blocked; if the signal handler returns then all open streams are closed and flushed and the program terminates (dumping core if appropriate). This means that theabort
call never returns. Because of this characteristic, it is often used to signal fatal conditions in support libraries, situations where the current operation cannot be completed but the main program can perform cleanup before exiting. It is used when an assertion fails.
That means that if your code is not calling abort
directly nor sending itself the SIGABRT
signal via raise
, and you don't have any failing assertions, the cause must be that a support library (which could be libc) has encountered an internal error. If you provide the details of your program we might be able to suggest possible causes. Even better, if you examine a core or run your program in a debugger you should be able to collect a stack trace, which will show which library caused your program to abort.
(It is also possible that another program on your system is sending your program SIGABRT
, but this is in most cases vanishingly unlikely.)

- 152,476
- 27
- 293
- 366
This usually happens when libraries encounter internal error, so they call abort(), because they cant continue. This might happen when you overwrite one of it's data structures (the one which belongs to the function from libc for example). So this might be e.g. libc calling because you did overwrite something. And the application must then terminate because it's impossible to continue or handle it, which is called failed assertion.

- 1,037
- 9
- 17
In practice this is usually triggered by the assert macro:
char* foo = NULL;
assert( foo != NULL );
would result in SIGABRT

- 11,181
- 5
- 39
- 59