Re: enif_make_int64 => -0 for INT64_MIN with gcc 4.9.1

Tuncer Ayaz <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <CAOvwQ4joCFZ6x0JDALrMNabi98X6pm0hpZ4trCcTna+2sqPObA@mail.gmail.com>
On Sun, Jul 20, 2014 at 3:27 AM, Tomas Abrahamsson wrote:
> Hi,
>
> I upgraded gcc from version 4.8.1 to 4.9.1, recompiled Erlang/OTP-17.1.1
> and my nif, and now enif_make_int64 creates -0 for INT64_MIN.
>
>   % make test
>   erl -s int64nif go -s erlang halt
>   Erlang/OTP 17 [erts-6.1.1] [source] [smp:4:4] [async-threads:10]
> [kernel-poll:false]
>
>   -0
>
> When Erlang was compiled with gcc-4.8.1, it printed -9223372036854775808,
> I've attached the test programs, here are the important lines:
>
>     go() ->
>         io:format("~p~n", [int64_from_nif()]).
>
> The NIF C-code contains:
>
>     static ERL_NIF_TERM
>     int64_from_nif(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
>     {
>         return enif_make_int64(env, INT64_MIN);
>     }
>
> System information:
>
>   OS: linux, 32-bit core i5, 3.14-1-686-pae (debian unstable)
>   Erlang/OTP: built from scratch (both times) from the OTP-17.1.1 git tag.
>   gcc: initially: gcc (Debian 4.8.1-10) 4.8.1
>        with this one, it prints -9223372036854775808
>   gcc: after upgrade: gcc (Debian 4.9.1-1) 4.9.1
>        with this one, it prints -0
>
> The only change I did was apt-get install gcc and then rebuilding Erlang.

I can confirm this on linux amd64.

17.1.2  gcc 4.8.2 -> -9223372036854775808
17.1.2  gcc 4.9.0 -> -0
17.1.2  gcc 4.9.1 -> -0

16B03-1 gcc 4.8.2 -> -9223372036854775808
16B03-1 gcc 4.9.0 -> 0
16B03-1 gcc 4.9.1 -> 0


I suppose you're not able to distill this to stand-alone C code, right?

I don't think it will reveal anything, but it's an easy way to find
bugs, so maybe you can try building with -fsanitize=undefined. If you
want to do that, I'd suggest to apply the patch available at
https://github.com/erlang/otp/pull/429 and run
"configure --enable-sanitizers=undefined".
_______________________________________________
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.