[erlang-questions] Binaries problem

Francesco Pierfederici fpierfed@REDACTED
Wed May 2 02:09:01 CEST 2007


I have encountered a problem with handling binaries and I do not know
what the cause might be. In a nutshell, I seem to be unable to
assemble binaries larger than 2097149 bytes:


test(FileName, NumBytes) ->
    {ok, Fd} = file:open(FileName, [raw, binary]),
    {ok, Data} = file:read(Fd, NumBytes),

    NumRestBits = NumBytes * 8 - 1,
    <<Bit:1, Rest:NumRestBits>> = Data,

    NewData = <<Rest:NumRestBits, 0:1>>,

And then

inanna> erl
Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [hipe]

Eshell V5.5.4  (abort with ^G)
1> c(test).
./test.erl:11: Warning: variable 'Bit' is unused
./test.erl:13: Warning: variable 'NewData' is unused
2> test:test('/Users/fpierfed/Desktop/software/xcode_2.4.1_8m1910_6936315.dmg',
3> test:test('/Users/fpierfed/Desktop/software/xcode_2.4.1_8m1910_6936315.dmg',

=ERROR REPORT==== 1-May-2007::16:33:57 ===
Error in process <0.37.0> with exit value:

** exited: {badarg,[{test,test,2},
                    {shell,eval_loop,3}]} **

Is this a bug? Am I doing something wrong?

Thank you!

P.S. I am running this on a Mac OS X box using both R11B-4 and the
latest snapshot (R11B_2007-05-01) with identical results.
P.P.S. I get the same results with different files so there seems to
be nothing peculiar about the 900+ MB XCode file.

More information about the erlang-questions mailing list