Runtime Errors: SIGFPE and SIGABRT

Runtime errors are the errors that occur in computer programs during execution. When these errors occur, the program crashes, behave unexpectedly, or terminates. Software developers use different techniques to identify and resolve them, which include debugging tools and error-handling mechanisms.

 The following are various types of runtime errors:

  • Logical error

  • Input/Output error

  • Undefined object error

  • Division by zero error and many more

Now, we'll discuss two runtime errors in this answer:

SIGFPE

It stands for signal floating-point exception. This error particularly deals with floating point arithmetic. It usually occurs when an improper arithmetic operation with floating-point numbers is performed, like trying to divide by zero or calculating the square root of a negative value.

The SIGFPE error can be occurred due to three main factors:

  1. Division by zero.

  2. Attempting a modulo operation by zero.

  3. Encountering integer overflow.

Coding example

Here is an example of SIGFPE error:

#include <iostream>
using namespace std;
int main()
{
int num = 8;
cout << num / 0;
return 0;
}

When the above code is executed, it may cause the program to terminate abnormally, and the error message indicates a floating point exception occurring, but the exact behavior can vary based on the compiler and platform.

SIGABRT

SIGABRT is a signal in Unix-like systems like Linux and macOS, known by its "signal abort" abbreviation. It acts as an error detectable by programs, sent to initiate process termination. When a program gets the SIGABRT signal, it usually does cleanup tasks before ending. While the code will still compile, the warning will alert us to a potential issue that could lead to unexpected behavior during runtime.

The SIGABRT error can be occurred due to various factors; some are:

  1. Memory allocation failure

  2. Uncaught exceptions

  3. Stack Overflow and many more

Coding example

Here is an example of a SIGABRT error:

#include <iostream>
using namespace std;
int main()
{
int num = 10000000000;
int* array = new int[num];
return 0;
}

The code above caused a SIGABRT error. This occurred because the new operator couldn't get enough memory due to insufficient available memory, as the error message indicates that an overflow occurred during an implicit constant conversion.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved