Re: [PATCH] correct conversion of MIN_SMALL numeral to fixnum

Jesper Louis Andersen <[email protected]> Wed, 20 Aug 2014 11:49:23 +0200
Newsgroups gmane.comp.lang.erlang.patches
Message-ID <CAGrdgiWT71bNQUHjbZiK0UmgYEGHTtieFDSxpu7zee7_sBMABQ@mail.gmail.com>
I would definitely add test cases for this to the test suite. It warrants
one on the evil corner case numbers to make sure they are right in the
future.


On Wed, Aug 20, 2014 at 9:53 AM, Mikael Pettersson <[email protected]>
wrote:

> Conversion of MIN_SMALL as a numeral to an Erlang integer, via
> binary_to_integer/1 or list_to_integer/1, succeeds but creates
> the integer as a negative bignum.  This is incorrect as (a) the
> value fits in a fixnum, and (b) the VM expects values that fit
> in fixnums to also be fixnums.  The bug is that the numeral is
> converted first as a non-negative number, and then finally
> negated if prefixed by a unary minus sign.  MIN_SMALL without
> the sign is MAX_SMALL+1, which doesn't fit in a fixnum, so the
> value before the negation is a bignum.  To correct the
> representation after the negation call big_plus_small with zero,
> as already done in other places.
>
> Tested with the emulator testsuite on Linux/x86_64, no regressions.
>
> Thanks to Jesper Louis Andersen for the report to erlang-bugs.
>
> Signed-off-by: Mikael Pettersson <[email protected]>
>
> Links:
>
> git fetch git://github.com/mikpe/otp.git MIN_SMALL-to-integer
>
> https://github.com/mikpe/otp/compare/erlang:maint...MIN_SMALL-to-integer
>
> https://github.com/mikpe/otp/compare/erlang:maint...MIN_SMALL-to-integer.patch
>
> https://github.com/erlang/otp/pull/452
> _______________________________________________
> erlang-patches mailing list
> [email protected]
> http://erlang.org/mailman/listinfo/erlang-patches
>



-- 
J.

_______________________________________________
erlang-patches mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-patches