Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes a SIGABRT fault?

Tags:

c++

Could you please tell me what could possibly cause a SIGABRT fault in C++?

like image 603
user1444426 Avatar asked Jun 22 '12 17:06

user1444426


People also ask

What is a SIGABRT error?

A SIGABRT (signal abort) error means that the app was deliberately crashed due to some really bad problem, like a runtime error during the start-up sequence or a bad or unreadable user interface file.

How do you avoid SIGABRT error?

Resize the arrays to 0 first. Otherwise, resize is supposed to copy the content that is common in the two arrays, so it will need to first allocate a new entrie array, copy everything, then release the old one.

What SIGABRT means?

Signal 5 ( SIGTRAP ) = “General crash” Signal 6 ( SIGABRT ) = SIGABRT is commonly used by libc and other libraries to abort the program in case of critical errors. For example, glibc sends an SIGABRT in case of a detected double-free or other heap corruptions.

How do you debug a signal SIGABRT?

For SIGABRT errors, run in debug until the program crashes. Then, there should be a little black button with the text "GDB" in yellow over it above your code editor in your mini-debugging bar. Click it, and it will bring up your debugger console.


1 Answers

Per Wikipedia,

SIGABRT is sent by the process to itself when it calls the abort libc function, defined in stdlib.h. The SIGABRT 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 the abort 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.)

like image 135
ecatmur Avatar answered Sep 20 '22 19:09

ecatmur