<div dir="ltr"><div><span style="font-size:13px">I sent this yesterday but it doesn't look like it went through, so apologies if anyone gets this twice.</span></div><div><span style="font-size:13px"><br></span></div><span style="font-size:13px"><div><span style="font-size:13px"><br></span></div>Calculating math:pow(2, -1075) returns 0 on Linux, but causes an</span><br style="font-size:13px"><span style="font-size:13px">exception on a Solaris-based system. This was causing some crashes in</span><br style="font-size:13px"><span style="font-size:13px">RabbitMQ when it tries to calculate math:exp with inputs less than</span><br style="font-size:13px"><span style="font-size:13px">-745.133.</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">Using OTP 17.4 on OmniOS r151006.</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">--</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">Erlang/OTP 17 [erts-6.3] [source] [smp:24:24] [async-threads:10]</span><br style="font-size:13px"><span style="font-size:13px">[hipe] [kernel-poll:false]</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">Eshell V6.3  (abort with ^G)</span><br style="font-size:13px"><span style="font-size:13px">1> math:pow(2, -1074.999).</span><br style="font-size:13px"><span style="font-size:13px">5.0e-324</span><br style="font-size:13px"><span style="font-size:13px">2> math:pow(2, -1074) * math:pow(2, -1).</span><br style="font-size:13px"><span style="font-size:13px">0.0</span><br style="font-size:13px"><span style="font-size:13px">3> math:pow(2, -1075).</span><br style="font-size:13px"><span style="font-size:13px">** exception error: an error occurred when evaluating an arithmetic expression</span><br style="font-size:13px"><span style="font-size:13px">     in function  math:pow/2</span><br style="font-size:13px"><span style="font-size:13px">        called as math:pow(2,-1075)</span><br style="font-size:13px"><span style="font-size:13px">4> math:exp(-745).</span><br style="font-size:13px"><span style="font-size:13px">5.0e-324</span><br style="font-size:13px"><span style="font-size:13px">5> math:exp(-746).</span><br style="font-size:13px"><span style="font-size:13px">** exception error: an error occurred when evaluating an arithmetic expression</span><br style="font-size:13px"><span style="font-size:13px">     in function  math:exp/1</span><br style="font-size:13px"><span style="font-size:13px">        called as math:exp(-746)</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">--</span><br style="font-size:13px"><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">Running this in gdb, it looks like the matherr function in</span><br style="font-size:13px"><span style="font-size:13px">sys/unix/sys_float.c is being called on Solaris but not on Linux,</span><br style="font-size:13px"><span style="font-size:13px">possibly because the Linux version of libm requires the _SVID_SOURCE</span><br style="font-size:13px"><span style="font-size:13px">feature test macro in order to call the function (</span><br style="font-size:13px"><a href="http://man7.org/linux/man-pages/man3/matherr.3.html" target="_blank" style="font-size:13px">http://man7.org/linux/man-pages/man3/matherr.3.html</a><span style="font-size:13px"> ).</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">OmniOS (Solaris libm):</span><br style="font-size:13px"><span style="font-size:13px">--</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">0xfeeba733 in ?? () from /lib/libm.so.2</span><br style="font-size:13px"><span style="font-size:13px">(gdb)</span><br style="font-size:13px"><span style="font-size:13px">0xfeeb63c0 in matherr@plt () from /lib/libm.so.2</span><br style="font-size:13px"><span style="font-size:13px">(gdb)</span><br style="font-size:13px"><span style="font-size:13px">matherr (exc=0xfdeffdac) at sys/unix/sys_float.c:839</span><br style="font-size:13px"><span style="font-size:13px">839     {</span><br style="font-size:13px"><span style="font-size:13px">(gdb)</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">--</span><br style="font-size:13px"><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">Linux:</span><br style="font-size:13px"><span style="font-size:13px">--</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">0x00007fb6a1d0e9a7 in pow () from /lib/x86_64-linux-gnu/libm.so.</span><span style="font-size:13px">6</span><br style="font-size:13px"><span style="font-size:13px">(gdb)</span><br style="font-size:13px"><span style="font-size:13px">0x00007fb6a1ced550 in matherr@plt () from /lib/x86_64-linux-gnu/libm.so.</span><span style="font-size:13px">6</span><br style="font-size:13px"><span style="font-size:13px">(gdb)</span><br style="font-size:13px"><span style="font-size:13px">0x00007fb6a1d33f00 in ?? () from /lib/x86_64-linux-gnu/libm.so.</span><span style="font-size:13px">6</span><br style="font-size:13px"><span style="font-size:13px">(gdb)</span><br></div>