|
From: | Paul Eggert |
Subject: | Re: checking against signed integer overflow |
Date: | Sun, 6 Dec 2020 17:56:48 -0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 |
On 12/6/20 12:21 PM, Bruno Haible wrote:
Did we discuss the signal with which the process should be terminated? Division by zero and (INT_MIN / -1) raise a SIGFPE signal (at least on some CPUs), and this signal is defined as "Erroneous arithmetic operation." [1] Like you say, signed integer overflow should raise the same signal. Then, SIGILL is just as wrong as SIGABRT.
I don't remember whether we discussed which signal should be given.This issue has been a mess for decades; SIGFPE originally was meant just for floating-point exceptions but got hijacked by some integer operations on many platforms. At this point it would be better for integer arithmetic overflow to generate SIGFPE in some way that a signal handler could tell the difference, but this is not a hill I'm prepared to die on and if it requires significantly more runtime library code or extra instructions in the executable I wouldn't bother. It's enough for me that *some* otherwise-unlikely but fatal signal is generated.
[Prev in Thread] | Current Thread | [Next in Thread] |