[erlang-bugs] R14B04 and R15A: Possible bug when compiling code using binary expressions with hipe

Magnus Klaar <>
Sat Dec 10 17:37:59 CET 2011

On Sat, Dec 10, 2011 at 10:14 AM, Kostis Sagonas <> wrote:
> Thanks for the bug report.  This was mote than enough information to
> reproduce the compiler crash and pinpoint where it occurs.  For the file
> that contains it, it happens in function word/2 and I suggest that for the
> time being you modify the first clause of that function to contain _/binary
> instead of _/bits.  This will bypass the problem and I think it will allow
> cowboy to be compiled to native code.
> However, the native compiler crash should be fixed.  It really boils down
> to the following code:
>  -module(cowboy).
>  -export([f/1]).
>  f(<<42, _/bits>> = B) -> B.
> for which the BEAM compiler produces:
>  label 1:
>    {func_info,{atom,cowboy},{**atom,f},1}
>  label 2:
>    {test,bs_start_match2,{f,1},[{**x,0},1,0,{x,1}]}
>    {test,bs_match_string,{f,1},[{**x,1},8,<<"*">>]}
>    return
> This is obviously correct BEAM code, but I think it's suboptimal. I would
> have expected some lighter-weight instruction instead of a bs_match_string
> one, which presumably involves some loop in its implementation.  Bjorn what
> say you?
> Anyway, the crash is not due to that.  It's due to this instruction not
> being followed by some other one, like a bs_check_unit or a bs_test_tail.
>  This confuses the native code compiler.
> I will fix this, but I am afraid it's too late for R15B.
> Kostis


Thanks for the quick reply and for verifying that my approach to working
around the issue wasn't completely brain dead (better safe than sorry).

/ Magnus Klaar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20111210/0849c6ee/attachment.html>

More information about the erlang-bugs mailing list