I just tried the C version and it compiles and exits gracefully with gcc 4.2.1.
IDIV DoS (INT_MIN / -1)
11–20 of 24 posts
Re: IDIV DoS (INT_MIN / -1)
#12I just tried the C version and it compiles and exits gracefully with gcc 4.2.1.
int main(int argc, char *argv[]) { return (1LL
Note that this issue has been written about before by Tavis Ormandy: http://my.opera.com/taviso/blog/show.dml/639454Re: IDIV DoS (INT_MIN / -1)
#13I just tried the C version and it compiles and exits gracefully with gcc 4.2.1.
The example the article gives isn't a general C problem, it's a common bug in some (mostly older) C/C++ compilers. As you point out GCC does not have this bug.
Re: IDIV DoS (INT_MIN / -1)
#14Earlier quoted context omitted.
The example the article gives isn't a general C problem, it's a common bug in some (mostly older) C/C++ compilers. As you point out GCC does not have this bug.
It's not a bug, it's intended to be undefined behavior; see http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html... (issue 1450)
Re: IDIV DoS (INT_MIN / -1)
#15Earlier quoted context omitted.
It's not a bug, it's intended to be undefined behavior; see http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html... (issue 1450)
Regardless of undefined behavior, it should not crash the compiler.
Re: IDIV DoS (INT_MIN / -1)
#16I just tried the C version and it compiles and exits gracefully with gcc 4.2.1.
define i64 @crash() nounwind uwtable readnone optsize {
ret i64 undef
}
In machine code terms, on x86-64 this turns into a function composed entirely of the ret opcode. gcc-4.6 adds an xor eax, eax before the ret.Re: IDIV DoS (INT_MIN / -1)
#17I just tried the C version and it compiles and exits gracefully with gcc 4.2.1.
Also, what optimization level did you run with?
Re: IDIV DoS (INT_MIN / -1)
#18I just tried the C version and it compiles and exits gracefully with gcc 4.2.1.
That's probably because the code in the article uses compile-time constants as operands. Try this one and pass "-1" as the command-line parameter: int main(int argc, char *argv[]) { return (1LL Note that this issue has been written about before by Tavis Ormandy: http://my.opera.com/taviso/blog/show.dml/639454
Re: IDIV DoS (INT_MIN / -1)
#19I just tried the C version and it compiles and exits gracefully with gcc 4.2.1.
Would you mind posting the output of gcc -S ? Also, what optimization level did you run with?
Re: IDIV DoS (INT_MIN / -1)
#20If anyone here has used Second Life's scripting language LSL, they had to work around this issue. Apparently they now calculate x / -1 as -x instead, which gets a counter-intuitive result when x=INT_MIN but doesn't crash. I believe once upon a time this was documented and everything.
Assuming x86 signed overflow behavior, you're just back to INT_MIN again? Or am I crazy?