Bug 7604 - Floating point exception - Fuzz Testing
Summary: Floating point exception - Fuzz Testing
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.21.x
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-06 20:25 UTC by Fernando Muñoz
Modified: 2014-11-18 13:34 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fernando Muñoz 2014-11-06 20:25:29 UTC
Following code generates Floating point exception:

echo $(( 2**63 % -1 ))

I don't have debug symbols installed at the moment, sorry.

Reading symbols from busybox...(no debugging symbols found)...done.
(gdb) run sh -c 'echo $(( 2**63 % -1 ))'
Starting program: /bin/busybox sh -c 'echo $(( 2**63 % -1 ))'

Program received signal SIGFPE, Arithmetic exception.
0x0000000000423b85 in ?? ()


This exception only appear on 64 bits apparently, tried on 32 bits but it didn't occur.
Comment 1 Denys Vlasenko 2014-11-18 13:34:04 UTC
The same happens in bash.

The cause is that MAX_NEGATIVE_INT / -1 = MAX_POSITIVE_INT+1 and thus is not representable. Therefore these ops fail:

                        rez /= right_side_val;

                        rez %= right_side_val;

They dont fail in 32-bit case because 64-bit wide divide in 32-bit case is handled as a several divides of smaller width. The result is wrong, though (since correct result is not representable),

Fixed in git. Thanks!