[erlang-bugs] Weird exception error return involving bitstrings
Tue Oct 30 08:56:05 CET 2012
On Mon, Oct 29, 2012 at 11:56 PM, Adam Rutkowski <> wrote:
> I am facing weird behaviour for the following code:
> bar(<<>>) -> ok;
> bar(Bin) when is_bitstring(Bin) andalso not is_binary(Bin) ->
> bar(<<Bin/binary, 0:1>>);
> bar(<<_:8/integer, Rest/binary>>) ->
> foobar1_test() -> ok = bar(<<1,2,3>>).
> foobar2_test() -> ok = bar(<<256:8>>).
> foobar3_test() -> ok = bar(<<256:7>>).
> foobar4_test() -> ok = bar(<<1,2,3>>).
Yes, there are two bugs in the error handling when
appending to a binary.
* If the binary has not been previously been appended
to, the exception type would not be set if an exception
was generated, leading to random exceptions.
* If the binary had been previously appended to, no
exception would be generated if (for example) unit was
set to 8 bits and the size of the binary was not a
multiple of 8 bits.
We will fix both bugs in R15B03.
Björn Gustavsson, Erlang/OTP, Ericsson AB
More information about the erlang-bugs