[erlang-patches] Per-thread FPE pointer not being initialized

Raimo Niskanen raimo+erlang-patches@REDACTED
Wed Jul 1 10:07:15 CEST 2009


I can not reproduce it - that would need exact match
of floating point exception vs signals i guess.
I see no harm ininitializing an allocated buffer
(except for performance) but suspect the bug might be elswhere.
The patch is scheduled for R13B02 and I will check
with the guys that know better if the fix should
be somewhere else...

On Tue, Jun 30, 2009 at 07:34:39PM -0700, David Reiss wrote:
> The per-thread last floating point exception pointer is not initialized to
> NULL when it is allocated.  As a result, spurious floating point
> exceptions are reported.
> 
> This is 100% reproducible for me on CentOS 5.1 for x86-64, with Erlang/OTP
> R13B built from source with gcc 2.5 and gcc 4.1.2.  It doesn't happen with
> R13B01, but, based on the nature of the bug, I think that is most likely
> due to chance.
> 
> Steps to reproduce:
> 
> 1/ Start up a node with
>   dreiss@REDACTED:~$ erl -noshell -name bob@`hostname`
> 
> 2/ Build and compile test program
>   dreiss@REDACTED:~$ cat test.erl
>   -module(test).
>   -export([start/1]).
>   start([Remote]) ->
>     rpc:call(Remote, erlang, is_float, [750.0]).
>   dreiss@REDACTED:~$ erlc test.erl
> 
> 3/ Run test program
>   dreiss@REDACTED:~$ erl -noshell -name alice@`hostname` -pz . -s test
> start bob@`hostname` -s init stop
> 
> The "alice" node exits with no output.  After running the "alice" command,
> the "bob" node prints the following
> 
>   ERTS_FP_CHECK_INIT at 0x4aaded: detected unhandled FPE at 0x2
> 
> Patch:
> 
> diff otp_src_R13B/erts/emulator/sys/unix/sys_float.c
> otp_src_R13B/sys/unix/sys_float.c/sys/unix/sys_float.c
> --- otp_src_R13B/erts/emulator/sys/unix/sys_float.c	2009-06-30
> 17:53:31.000000000 -0700
> +++ otp_src_R13B/erts/emulator/sys/unix/sys_float.c	2009-06-30
> 17:53:31.000000000 -0700
> @@ -57,7 +57,8 @@
>  void erts_thread_init_fp_exception(void)
>  {
>      unsigned long *fpe = erts_alloc(ERTS_ALC_T_FP_EXCEPTION, sizeof(*fpe));
> +    *fpe = 0;
>      erts_tsd_set(fpe_key, fpe);
>  }
> 
> 
> 
> --David
> 
> ________________________________________________________________
> erlang-patches mailing list. See http://www.erlang.org/faq.html
> erlang-patches (at) erlang.org

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


More information about the erlang-patches mailing list