[erlang-bugs] FreeBSD FPE issue on ERTS_FP_CHECK_INIT Re: ERTS_FP_CHECK_INIT error of HiPE in 18.0-rc1 running on FreeBSD 10.1-STABLE
Mikael Pettersson
mikpelinux@REDACTED
Sun May 3 13:25:12 CEST 2015
Mikael Pettersson writes:
> Mikael Pettersson writes:
> > Kenji Rikitake writes:
> > > Thanks Mikael for the confirmation.
> > >
> > > So can I conclude this as a bug or FPE handling
> > > difference between gcc and clang?
> >
> > Yes. I have a reduced testcase in plain C99 which works with gcc
> > but shows wrong behaviour when compiled by clang. It involves
> > converting a double with value somewhere between INT64_MAX and
> > UINT64_MAX to uint64_t: clang causes that to signal FP_INVALID.
> >
> > At the moment I'm trying to get confirmation about where the
> > error lies: in the test case (i.e., the Erlang VM), or in clang.
> > According to my reading of the C standard, clang is in error.
>
> I've had a look in clang/llvm's bugzilla, and it's clear that clang/llvm
> does not support FP exceptions in any way -- both due to backend bugs
> and due to their middle-end being reckless. See e.g. PRs 17686, 22873,
> and 8100.
>
> I'll prepare a patch to force-disable FP exceptions if clang is detected.
>
> /Mikael
https://github.com/erlang/otp/pull/707
>
> >
> > For now, the workaround is to either compile with gcc, or to
> > build with ./configure --disable-fp-exceptions.
> >
> > /Mikael
> >
> > > (I noticed on my OS X the *gcc-compiled* 18.0-rc1
> > > didn't cause the problem either.)
> > >
> > > Regards,
> > > Kenji Rikitake
> > >
> > > On Sat, May 2, 2015 at 3:04 AM, Mikael Pettersson <mikpelinux@REDACTED>
> > > wrote:
> > >
> > > > Kenji Rikitake writes:
> > > > > Mikael:
> > > > >
> > > > > I managed to reduce the problem to a one-liner.
> > > > > Executing
> > > > > trunc(0.8 * (1 bsl 128))
> > > > > will generate the SIGFPE.
> > > >
> > > > I can reproduce the SIGFPE on Linux/x86_64 by compiling OTP-18-rc1 with
> > > > clang-3.6.0.
> > > >
> > > >
> > > > >
> > > > > I attached the gdb of FreeBSD 10.1-STABLE to the Erlang beam.smp and
> > > > generated
> > > > > the following output.
> > > > > Regards,
> > > > > Kenji Rikitake
> > > > >
> > > > > --- Erlang shell output:
> > > > >
> > > > > Erlang/OTP 18 [RELEASE CANDIDATE 1] [erts-7.0] [source-71bfef4]
> > > > [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false] [dtrace]
> > > > >
> > > > > Eshell V7.0 (abort with ^G)
> > > > > 1> trunc(0.8 * (1 bsl 128)).
> > > > > %%% here FPE is issued and the gdb shows the value...
> > > > > fpe_sig_action: FPE at 0x4ca1b7
> > > > > 272225893536750785882272431128279252992
> > > > > 2> trunc(0.8 * (1 bsl 128)).
> > > > > ERTS_FP_CHECK_INIT at 0x571e60: detected unhandled FPE at
> > > > 0x4cafpe_sig_action: FPE at 0x4ca1b7
> > > > > 272225893536750785882272431128279252992
> > > > > 3> q()
> > > > > ok
> > > > >
> > > > > --- output of attached gdb:
> > > > >
> > > > > Continuing.
> > > > >
> > > > > Program received signal SIGFPE, Arithmetic exception.
> > > > > [Switching to Thread 80240a000 (LWP 101243/beam.smp)]
> > > > > double_to_integer (p=0x8031c0398, x=1.4757395258967642e+19) at
> > > > beam/erl_bif_guard.c:302
> > > > > 302 d = x; /* trunc */
> > > > > Current language: auto; currently minimal
> > > > > (gdb) print $mxcsr
> > > > > $1 = 6401
> > > > > (gdb) disassemble double_to_integer
> > > > > Dump of assembler code for function double_to_integer:
> > > > > [...]
> > > > > 0x00000000004ca1b7 <double_to_integer+519>: cvttsd2siq %xmm1,%rcx
> > > > > [...]
> > > > > End of assembler dump.
> > > > > (gdb) print $mxcsr
> > > > > $3 = 6401
> > > > > (gdb) print $xmm1
> > > > > $4 = {f = {-1.58818684e-23, 467.199982, 0, 0}}
> > > > > (gdb) print $rcx
> > > > > $5 = -9223372036854775808
> > > > >
> > > > > [End of log]
> > > > >
> > > > > ++> Kenji Rikitake <kenji@REDACTED> [2015-04-27 21:53:44 +0900]:
> > > > > > Date: Mon, 27 Apr 2015 21:53:44 +0900
> > > > > > From: Kenji Rikitake <kenji@REDACTED>
> > > > > > To: Mikael Pettersson <mikpelinux@REDACTED>
> > > > > > Cc: erlang-bugs@REDACTED
> > > > > > Subject: Re: [erlang-bugs] FreeBSD FPE issue on ERTS_FP_CHECK_INIT Re:
> > > > > > ERTS_FP_CHECK_INIT error of HiPE in 18.0-rc1 running on FreeBSD
> > > > > > 10.1-STABLE
> > > > > >
> > > > > > FYI:
> > > > > > A reference on a similar issue on OS X:
> > > > > > http://erlang.org/pipermail/erlang-bugs/2011-May/002383.html
> > > > > >
> > > > > > The instruction caused the exception was "cvttsd2siq".
> > > > > >
> > > > > > Kenji Rikitake
> > > > > >
> > > > > > ++> Kenji Rikitake <kenji@REDACTED> [2015-04-27 21:16:14 +0900]:
> > > > > > > > Can you provide a disassembly of erts_gc_trunc_1 from this build?
> > > > > > >
> > > > > > > > Can you provide a disassembly of gc_double_to_integer from this
> > > > build?
> > > > > > >
> > > > > > > I will send you personally (not on the list).
> > > > > > _______________________________________________
> > > > > > erlang-bugs mailing list
> > > > > > erlang-bugs@REDACTED
> > > > > > http://erlang.org/mailman/listinfo/erlang-bugs
> > > >
> > > > --
> > > >
> >
> > --
>
> --
--
More information about the erlang-bugs
mailing list