Different handling of floating point underflows between Linux and Solaris-based OSes

Corey Cossentino <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <CAGviAg9Se1G4u3ZqbzDMhf7diLF6OGfoDxTjJCtHPLO8hFGyFA@mail.gmail.com>
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@plt () 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@plt () from /lib/x86_64-linux-gnu/libm.so.6
(gdb)
0x00007fb6a1d33f00 in ?? () from /lib/x86_64-linux-gnu/libm.so.6
(gdb)

_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.