[erlang-bugs] io_list_to_binary returns wrong result for iolist of length 2^32

Erik Søe Sørensen ess@REDACTED
Wed Apr 13 15:38:30 CEST 2011


To reproduce:

    $ erl
    Erlang R14B (erts-5.8.1) [source] [64-bit] [smp:8:8] [rq:8]
    [async-threads:0] [kernel-poll:false]

    Eshell V5.8.1  (abort with ^G)
    [snip]
    6> iolist_to_binary(lists:foldl(fun(_,A) -> [A|A] end, [64],
    lists:seq(1,32))).
    <<>>
    7>
    size(v(-1)).                                                              
     
    0
    8> iolist_to_binary(lists:foldl(fun(_,A) -> [A|A] end, [64],
    lists:seq(1,31))).
    HUGE size (8589934632)
    Aborted


-- So, length 2^31 aborts the VM while 2^32 "simply" returns a wrong result.

For size 2^31, I hypothesized that something went wrong when Eshell 
memorizes the result, but that does not appear to be the case:

    erik@REDACTED:riak_kv-basho$ erl
    Erlang R14B (erts-5.8.1) [source] [64-bit] [smp:8:8] [rq:8]
    [async-threads:0] [kernel-poll:false]

    Eshell V5.8.1  (abort with ^G)
    1> iolist_to_binary(lists:foldl(fun(_,A) -> [A|A] end, [64],
    lists:seq(1,31))), ok.
    HUGE size (8589934632)
    Aborted

These tests were run on:
$ uname -a
Linux flitwick 2.6.31-22-generic #73-Ubuntu SMP Fri Feb 11 19:18:05 UTC 
2011 x86_64 GNU/Linux


/Erik



More information about the erlang-bugs mailing list