[erlang-questions] Binary matching problem

Kostis Sagonas <>
Mon Feb 25 16:36:10 CET 2008

Tomas Stejskal wrote:
> It doesn't really work for me. I have erlang R12B-1 and it seems you've 
> tried it out on version R11B5, maybe it's a bug in R12.

This appears to be a BEAM compiler bug in R12B.  I cannot test it in 
vanilla R12B, but it's present even in the current development version, 
so I am certain it is the same problem.

Eshell V5.6.2  (abort with ^G)
1> c(id3_v1).
2> id3_v1:read_v1_or_v11_tag("id3_v1.mp3").

Incidentally, the problem disappears if you compile to native code via 
Core Erlang (but not via BEAM):

3> hipe:c(id3_v1, [core]).
4> id3_v1:read_v1_or_v11_tag("id3_v1.mp3").
       {artist,<<"Daniel Landa">>},
       {album,<<"Best Of">>}]}}

The problem is most probably due to generating erroneous control flow.
In the list of instructions:

           {f,15},                              <---------------
           {f,15},                              <---------------
     {test,bs_test_tail2,{f,15},[{x,0},8]}      <---------------
     {test,is_eq_exact,{f,15},[{x,4},{integer,0}]} <------------

the labels with the arrows should read {f,14} instead
(and perhaps there should be some bs_restore instructions in label 14).

Bjorn, now do your magic ;-)


More information about the erlang-questions mailing list