[erlang-bugs] Different handling of floating point underflows between Linux and Solaris-based OSes

Corey Cossentino corey@REDACTED
Thu Dec 25 06:15:06 CET 2014


I sent this yesterday but it doesn't look like it went through, so
apologies if anyone gets this twice.


Calculating math:pow(2, -1075) returns 0 on Linux, but causes an
exception on a Solaris-based system. This was causing some crashes in
RabbitMQ when it tries to calculate math:exp with inputs less than
-745.133.

Using OTP 17.4 on OmniOS r151006.

--

Erlang/OTP 17 [erts-6.3] [source] [smp:24:24] [async-threads:10]
[hipe] [kernel-poll:false]

Eshell V6.3  (abort with ^G)
1> math:pow(2, -1074.999).
5.0e-324
2> math:pow(2, -1074) * math:pow(2, -1).
0.0
3> math:pow(2, -1075).
** exception error: an error occurred when evaluating an arithmetic
expression
     in function  math:pow/2
        called as math:pow(2,-1075)
4> math:exp(-745).
5.0e-324
5> math:exp(-746).
** exception error: an error occurred when evaluating an arithmetic
expression
     in function  math:exp/1
        called as math:exp(-746)

--


Running this in gdb, it looks like the matherr function in
sys/unix/sys_float.c is being called on Solaris but not on Linux,
possibly because the Linux version of libm requires the _SVID_SOURCE
feature test macro in order to call the function (
http://man7.org/linux/man-pages/man3/matherr.3.html ).

OmniOS (Solaris libm):
--

0xfeeba733 in ?? () from /lib/libm.so.2
(gdb)
0xfeeb63c0 in matherr@REDACTED () from /lib/libm.so.2
(gdb)
matherr (exc=0xfdeffdac) at sys/unix/sys_float.c:839
839     {
(gdb)

--


Linux:
--

0x00007fb6a1d0e9a7 in pow () from /lib/x86_64-linux-gnu/libm.so.6
(gdb)
0x00007fb6a1ced550 in matherr@REDACTED () from /lib/x86_64-linux-gnu/libm.so.6
(gdb)
0x00007fb6a1d33f00 in ?? () from /lib/x86_64-linux-gnu/libm.so.6
(gdb)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20141225/2dfc4d13/attachment.htm>


More information about the erlang-bugs mailing list