Error in beam compiler (R14B01 on Widows XP)

Sergey Yelin <>
Tue Mar 15 08:20:26 CET 2011


Hi list,

I've found beam compiler error in R14B01.
Here is a simple program that works fine on R14B (erts-5.8.1.1) but fail in
R14B01 on the same environment (Windows XP SP3):

-module(problem7).
-export([find/2]).

find(0, _) ->
   0;
find(Nth, Max) ->
   lists:nth(Nth, findp(Max, [], lists:seq(2, Max))).

findp(_, _, []) ->
    [];
findp(Max, P, [X | T]) when X*X =< Max ->
    P1 = [X] ++ P,
    findp(Max, P1, [N || N <- T, N rem X =/= 0]);
findp(_, P, L) ->
    P ++ L.

Output for R14B01 (in werl.exe):

Erlang R14B01 (erts-5.8.2) [smp:4:4] [rq:4] [async-threads:0]

Eshell V5.8.2  (abort with ^G)
1> c(problem7).
./problem7.erl:none: internal error in beam_asm;
crash reason: {undef,
                  [{beam_asm,module,
                       [{problem7,
                            [{find,2},{module_info,0},{module_info,1}],
                            [],
                            [{function,find,2,2,
                                 [{label,1},
                                  {func_info,{atom,problem7},{atom,find},2},
                                  {label,2},

 {test,is_eq_exact,{f,3},[{x,0},{integer,0}]},
                                  return,
                                  {label,3},
                                  {allocate,2,2},
                                  {move,{x,0},{y,1}},
                                  {move,{integer,2},{x,0}},
                                  {move,{x,1},{y,0}},
                                  {call_ext,2,{extfunc,lists,seq,2}},
                                  {move,nil,{x,1}},
                                  {move,{x,0},{x,2}},
                                  {move,{y,0},{x,0}},
                                  {trim,1,1},
                                  {call,3,{f,5}},
                                  {move,{x,0},{x,1}},
                                  {move,{y,0},{x,0}},

 {call_ext_last,2,{extfunc,lists,nth,2},1}]},
                             {function,findp,3,5,
                                 [{label,4},

 {func_info,{atom,problem7},{atom,findp},3},
                                  {label,5},
                                  {test,is_nonempty_list,{f,6},[{x,2}]},
                                  {get_list,{x,2},{x,3},{x,4}},
                                  {gc_bif,'*',{f,7},5,[{x,3},{x,3}],{x,5}},
                                  {test,is_ge,{f,7},[{x,0},{x,5}]},
                                  {allocate_heap,2,2,5},
                                  {move,{x,0},{y,1}},
                                  {put_list,{x,3},{x,1},{y,0}},
                                  {move,{x,3},{x,1}},
                                  {move,{x,4},{x,0}},
                                  {call,2,{f,13}},
                                  {move,{y,0},{x,1}},
                                  {move,{x,0},{x,2}},
                                  {move,{y,1},{x,0}},
                                  {call_last,3,{f,5},2},
                                  {label,6},
                                  {test,is_nil,{f,7},[{x,2}]},
                                  {move,nil,{x,0}},
                                  return,
                                  {label,7},
                                  {move,{x,1},{x,0}},
                                  {move,{x,2},{x,1}},

 {call_ext_only,2,{extfunc,erlang,'++',2}}]},
                             {function,module_info,0,9,
                                 [{label,8},
                                  {func_info,
                                      {atom,problem7},
                                      {atom,module_info},
                                      0},
                                  {label,9},
                                  {move,{atom,problem7},{x,0}},
                                  {call_ext_only,1,
                                      {extfunc,erlang,get_module_info,1}}]},
                             {function,module_info,1,11,
                                 [{label,10},
                                  {func_info,
                                      {atom,problem7},
                                      {atom,module_info},
                                      1},
                                  {label,11},
                                  {move,{x,0},{x,1}},
                                  {move,{atom,problem7},{x,0}},
                                  {call_ext_only,2,
                                      {extfunc,erlang,get_module_info,2}}]},
                             {function,'-findp/3-lc$^0/1-0-',2,13,
                                 [{label,12},
                                  {func_info,
                                      {atom,problem7},
                                      {atom,'-findp/3-lc$^0/1-0-'},
                                      2},
                                  {label,13},
                                  {test,is_nonempty_list,{f,15},[{x,0}]},
                                  {get_list,{x,0},{x,2},{x,3}},

 {gc_bif,'rem',{f,14},4,[{x,2},{x,1}],{x,4}},
                                  {test,is_ne_exact,
                                      {f,14},
                                      [{x,4},{integer,0}]},
                                  {allocate,1,4},
                                  {move,{x,3},{x,0}},
                                  {move,{x,2},{y,0}},
                                  {call,2,{f,13}},
                                  {test_heap,2,1},
                                  {put_list,{y,0},{x,0},{x,0}},
                                  {deallocate,1},
                                  return,
                                  {label,14},
                                  {move,{x,3},{x,0}},
                                  {call_only,2,{f,13}},
                                  {label,15},
                                  {test,is_nil,{f,12},[{x,0}]},
                                  return]}],
                            16},
                        [],"z:/Projects/myeuler/problem7.erl",[]]},
                   {compile,beam_asm,1},
                   {compile,'-internal_comp/4-anonymous-1-',2},
                   {compile,fold_comp,3},
                   {compile,internal_comp,4},
                   {compile,internal,3}]}
error
2>


More information about the erlang-bugs mailing list