[erlang-questions] Problem with pattern matching in large binaries
Kostis Sagonas
kostis@REDACTED
Tue May 6 16:59:01 CEST 2008
Sverker Eriksson wrote:
>
> Per Gustafsson wrote:
>> I took a look at this and it seems that in the BYTE_OFFSET macro on line
>> 153 in erl_bits.h there is a cast to unsigned that really should be to
>> Uint that probably causes this problem, but I do not have a good machine
>> for testing this change. (Our amd64 does not have enough memory to build
>> a 1 Gb binary)
>
> I will take a look at this with my Intel Quad, 64bit, 4 Gb.
>
> If Per is right, a fix will be released to R12B-3.
I have not seen Per's mail on the mailing list (just the above reply),
but I can confirm that by modifying the macro on line 153 as Per
suggested, some things work as expected regarding big binary
construction on a 64 bit machine. For example, without the fix, I get:
1> B = <<1:(2 bsl 32)>>.
<<>>
which is clearly bogus, while with the fix:
1> B = <<1:(2 bsl 32)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
which seems much more likely to be the correct result. Indeed:
2> byte_size(B).
1073741824
3> 2 bsl 32.
8589934592
For those eager to try it: the fix is trivial and can be applied by
interested parties by hand, instead of waiting till the official release
of R12B-3.
Kostis
More information about the erlang-questions
mailing list