[erlang-bugs] possible bug with binary pattern matching

Jean-Marc Prud Homme jean-marc.prud-homme@REDACTED
Fri Mar 14 22:15:25 CET 2008


Hi,

 

We are experiencing crashes in the VM that seems to be related with
binary pattern matching.   It was successfully reproduced on Windows XP
and Linux Ubuntu 7.10 systems with R12B-0 and R12B-1.   The code below
was used to reproduce the crash.   It needs to be executed several times
to produce the crash.   

 

 

Regards,

 

Jean-Marc

 

 

- - - - - - - - - - - - - - - - 

 

%% Run the test 50 times

binary_test:run(50).    

 

 

- - - - - - - - - - - - - - - - 

-module(binary_test).

 

-compile(export_all).

 

run(N) ->

    

    T = <<8,1,9,1,0,8,1,9,1,0,8,1,9,1,0>>,

 

    F = fun() -> f1(T, {[test]}) end,

 

    repeat(N, F),

 

    ok.

 

repeat(0, _Fun) ->

    ok;

 

repeat(N, Fun) ->

    Fun(),

    repeat(N-1, Fun).

               

                                       

%% 1

f1(R, T) ->  

    f2(R, [T]).             

         

%% 2

f2(<<R/binary>>, T) ->      

   f3(R, {T}).                               

                                                

%% Never called but helps reproducing the crash

f3(<<L:8, T:L/binary-unit:8>>, a) -> 

    f4(T);

f3(<<L:8, T:L/binary-unit:8>>, b) -> 

    f4(T); 

f3(<<R/binary>>, c) -> 

    f4(0); 

 

%% 3

f3(<<R/binary>>, {T}) ->

    f3(R, T);

 

%% 4

f3(<<L:8, R/binary>>, [_]) ->

    f4([]);  

    

%% Never called but helps reproducing the crash

f3(<<L:8, T:L/binary-unit:8>>, d) -> 

    f4(T).    

                                             

%% 5    

f4(T) ->  

    f5({T}).      

 

%% 6       

f5(T) ->

    {T}.   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20080314/e80f90da/attachment.htm>


More information about the erlang-bugs mailing list