SIGFPE

SIGFPE

Infobox Computing signal
description = Erroneous arithmetic operation
action = Abnormal termination of the process
FPE_INTDIV | Integer divide by zero
FPE_INTOVF | Integer overflow
FPE_FLTDIV | Floating-point divide by zero
FPE_FLTOVF | Floating-point overflow
FPE_FLTUND | Floating-point underflow
FPE_FLTRES | Floating-point inexact result
FPE_FLTINV | Invalid floating-point operation
FPE_FLTSUB | Subscript out of range

SIGFPE is the signal sent to computer programs that perform erroneous arithmetic operations on POSIX compliant platforms. The symbolic constant for SIGFPE is defined in the header file signal.h. Symbolic signal names are used because signal numbers can vary across platforms.

Etymology

"SIG" is a common prefix for signal names; "FPE" is an acronym for "floating-point exception". Although SIGFPE does not necessarily involve floating-point arithmetic, there is no way to change its name without breaking backward compatibility.

Description

SIGFPE is sent to processes for a variety of reasons. A common example might be an unexpected type overflow (eg, unsigned integer) owing to exceptional input, or an error in a program construct.

SIGFPE can be handled. That is, programmers can specify the action they want to occur on receiving the signal, such as calling a subroutine, ignoring the event, or restoring the default action.

Under certain circumstances, ignoring SIGFPE can result in undefined behaviour. In particular, the program may hang as the offending operation is forever retried. However, it is safe to ignore SIGFPE signals not actually resulting from computation, such as those sent via the kill system call.

A common oversight is to consider division by zero the only source of SIGFPE conditions. On some architectures (IA-32 included), integer division of INT_MIN, the smallest representable negative integer value, by −1 triggers the signal because the quotient, a positive number, is not representable.

Example

Here is an example of an ANSI C program that attempts to perform an erroneous arithmetic operation, namely integer division by zero, or "FPE_INTDIV".

int main() { int x = 42/0; return 0; /* Never reached */ }

Compiling and running it on IA-32 with Linux produces the following:

$ gcc -o sigfpe sigfpe.c sigfpe.c: In function ‘main’: sigfpe.c:3: warning: division by zero $ ./sigfpe Floating point exception (core dumped)

A backtrace from gdb shows that the SIGFPE signal occurred in the main function:

Program received signal SIGFPE, Arithmetic exception. 0x08048373 in main ()

Compare the output from SIGFPE with that of a segmentation fault or the SIGILL signal for illegal instructions.

See also

* Division by zero
* Floating point


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • SIGFPE — Описание: Ошибочная арифметическая операция По умолчанию: завершение с дампом памяти коды SA SIGINFO FPE INTDIV Целочисленное деление на нуль FPE INTOVF Целочисленное переполнение FPE FLTDIV Деление на нуль с плавающей запятой FPE FLTOVF… …   Википедия

  • SIGFPE — Floating Point Exception Signal (Signal Nr. 8) unter X/Open, ATT und BSD UNIX erzeugt normalerweise ein Core Dump ( >xedit /usr/include/signal.h) …   Acronyms

  • SIGFPE — Floating Point Exception Signal (Signal Nr. 8) unter X/Open, ATT und BSD UNIX erzeugt normalerweise ein Core Dump ( >xedit /usr/include/signal.h) …   Acronyms von A bis Z

  • Signal (computing) — A signal is a limited form of inter process communication used in Unix, Unix like, and other POSIX compliant operating systems. Essentially it is an asynchronous notification sent to a process in order to notify it of an event that occurred. When …   Wikipedia

  • signal.h — Стандартная библиотека языка программирования С assert.h complex.h ctype.h errno.h fenv.h float.h inttypes.h iso646.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stdbool.h stddef.h …   Википедия

  • Quine (computing) — A quine s output is exactly the same as its source code A quine is a computer program which takes no input and produces a copy of its own source code as its only output. The standard terms for these programs in the computability theory and… …   Wikipedia

  • signal.h — Esta página o sección está siendo traducida, razón por la cual puede haber lagunas de contenidos, errores sintácticos o escritos sin traducir. Puedes colaborar con Wikipedia continuando con la traducción desde el artículo original. signal.h es un …   Wikipedia Español

  • Monad (functional programming) — In functional programming, a monad is a programming structure that represents computations. Monads are a kind of abstract data type constructor that encapsulate program logic instead of data in the domain model. A defined monad allows the… …   Wikipedia

  • Automatic differentiation — In mathematics and computer algebra, automatic differentiation, or AD, sometimes alternatively called algorithmic differentiation, is a method to numerically evaluate the derivative of a function specified by a computer program. Two classical… …   Wikipedia

  • SIGILL — Infobox Computing signal description = Illegal instruction action = Abnormal termination of the process ILL ILLOPC | illegal opcode ILL ILLOPN | illegal operand ILL ADR | illegal addressing mode ILL ILLTRP | illegal trap ILL PRVOPC | privileged… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”