<div dir="ltr">Thanks Mikael for the confirmation. <div><br></div><div>So can I conclude this as a bug or FPE handling<div>difference between gcc and clang?<div>(I noticed on my OS X the *gcc-compiled* 18.0-rc1</div><div>didn't cause the problem either.) </div></div><div><br></div><div>Regards,</div><div>Kenji Rikitake</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 2, 2015 at 3:04 AM, Mikael Pettersson <span dir="ltr"><<a href="mailto:mikpelinux@gmail.com" target="_blank">mikpelinux@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Kenji Rikitake writes:<br>
 > Mikael:<br>
 ><br>
 > I managed to reduce the problem to a one-liner.<br>
 > Executing<br>
 > trunc(0.8 * (1 bsl 128))<br>
 > will generate the SIGFPE.<br>
<br>
I can reproduce the SIGFPE on Linux/x86_64 by compiling OTP-18-rc1 with clang-3.6.0.<br>
<br>
<br>
 ><br>
 > I attached the gdb of FreeBSD 10.1-STABLE to the Erlang beam.smp and generated<br>
 > the following output.<br>
 > Regards,<br>
 > Kenji Rikitake<br>
 ><br>
 > --- Erlang shell output:<br>
 ><br>
 > Erlang/OTP 18 [RELEASE CANDIDATE 1] [erts-7.0] [source-71bfef4] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false] [dtrace]<br>
 ><br>
 > Eshell V7.0  (abort with ^G)<br>
 > 1> trunc(0.8 * (1 bsl 128)).<br>
 > %%% here FPE is issued and the gdb shows the value...<br>
 > fpe_sig_action: FPE at 0x4ca1b7<br>
 > 272225893536750785882272431128279252992<br>
 > 2> trunc(0.8 * (1 bsl 128)).<br>
 > ERTS_FP_CHECK_INIT at 0x571e60: detected unhandled FPE at 0x4cafpe_sig_action: FPE at 0x4ca1b7<br>
 > 272225893536750785882272431128279252992<br>
 > 3> q()<br>
 > ok<br>
 ><br>
 > --- output of attached gdb:<br>
 ><br>
 > Continuing.<br>
 ><br>
 > Program received signal SIGFPE, Arithmetic exception.<br>
 > [Switching to Thread 80240a000 (LWP 101243/beam.smp)]<br>
 > double_to_integer (p=0x8031c0398, x=1.4757395258967642e+19) at beam/erl_bif_guard.c:302<br>
 > 302             d = x;            /* trunc */<br>
 > Current language:  auto; currently minimal<br>
 > (gdb) print $mxcsr<br>
 > $1 = 6401<br>
 > (gdb) disassemble double_to_integer<br>
 > Dump of assembler code for function double_to_integer:<br>
 > [...]<br>
 > 0x00000000004ca1b7 <double_to_integer+519>:     cvttsd2siq %xmm1,%rcx<br>
 > [...]<br>
 > End of assembler dump.<br>
 > (gdb) print $mxcsr<br>
 > $3 = 6401<br>
 > (gdb) print $xmm1<br>
 > $4 = {f = {-1.58818684e-23, 467.199982, 0, 0}}<br>
 > (gdb) print $rcx<br>
 > $5 = -9223372036854775808<br>
 ><br>
 > [End of log]<br>
 ><br>
 > ++> Kenji Rikitake <<a href="mailto:kenji@k2r.org">kenji@k2r.org</a>> [2015-04-27 21:53:44 +0900]:<br>
 > > Date: Mon, 27 Apr 2015 21:53:44 +0900<br>
 > > From: Kenji Rikitake <<a href="mailto:kenji@k2r.org">kenji@k2r.org</a>><br>
 > > To: Mikael Pettersson <<a href="mailto:mikpelinux@gmail.com">mikpelinux@gmail.com</a>><br>
 > > Cc: <a href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
 > > Subject: Re: [erlang-bugs] FreeBSD FPE issue on ERTS_FP_CHECK_INIT Re:<br>
 > >  ERTS_FP_CHECK_INIT error of HiPE in 18.0-rc1 running on FreeBSD<br>
 > >  10.1-STABLE<br>
 > ><br>
 > > FYI:<br>
 > > A reference on a similar issue on OS X:<br>
 > > <a href="http://erlang.org/pipermail/erlang-bugs/2011-May/002383.html" target="_blank">http://erlang.org/pipermail/erlang-bugs/2011-May/002383.html</a><br>
 > ><br>
 > > The instruction caused the exception was "cvttsd2siq".<br>
 > ><br>
 > > Kenji Rikitake<br>
 > ><br>
 > > ++> Kenji Rikitake <<a href="mailto:kenji@k2r.org">kenji@k2r.org</a>> [2015-04-27 21:16:14 +0900]:<br>
 > > > > Can you provide a disassembly of erts_gc_trunc_1 from this build?<br>
 > > ><br>
 > > > > Can you provide a disassembly of gc_double_to_integer from this build?<br>
 > > ><br>
 > > > I will send you personally (not on the list).<br>
 > > _______________________________________________<br>
 > > erlang-bugs mailing list<br>
 > > <a href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
 > > <a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/listinfo/erlang-bugs</a><br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
</font></span></blockquote></div><br></div>