compile:forms/1 crashes

Bjorn Gustavsson bjorn@REDACTED
Tue Oct 4 17:03:10 CEST 2005


There is a bug in erl_lint in R10B and earlier. It will do some validation
only when it encounters an {eof,Line} term. If {eof,Line} is missing, it will,
for instance, not validate local function calls.

The workaround is to always include an {eof,Line} term as the last form
in the list.

The bug in erl_lint has already been fixed in our internal R11B development branch.
We might fix it in R10B-8 too.

/Björn

"Ulf Wiger (AL/EAB)" <ulf.wiger@REDACTED> writes:

> Using compiler-4.3.9 (the latest one).
> 
> I'm trying to generate some code, and am experiencing the 
> lack of user-friendliness in compile:forms/1. 
> Just about all errors in the generated forms manifest themselves
> as crashes in erl_lint or other. Below is a crash from beam_dead.
> 
> I'm not sure whether this is a bug in my generated code, or in
> the compiler.
> 
> /Uffe
> 
> 
> (foo@REDACTED)92> rdbms_validate:codegen([person], 1).
> [{attribute,1,module,rdbms_jit},
>  ...
> (foo@REDACTED)93> io:format("~p~n", [v(92)]).
> [{attribute,1,module,rdbms_jit},
>  {attribute,2,export,[{validate,2}]},
>  {function,3,
>            validate,
>            2,
>            [{clause,3,
>                     [{atom,3,person},{var,3,'Object'}],
>                     [],
>                     [{call,3,{atom,3,validate_person},[{var,3,'Object'}]}]}]},
>  {function,4,
>            validate_person,
>            2,
>            [{clause,4,
>                     [{atom,4,person},
>                      {tuple,4,
>                             [{var,4,person},
>                              {var,4,'V_id'},
>                              {var,4,'V_name'},
>                              {var,4,'V_addr'},
>                              {var,4,'V_age'}]}],
>                     [],
>                     [{'if',6,
>                            [{clause,6,
>                                     [],
>                                     [[{op,6,
>                                           '=/=',
>                                           {var,6,'V_id'},
>                                           {atom,6,'#.[].#'}}]],
>                                     [{atom,6,true}]},
>                             {clause,7,
>                                     [],
>                                     [[{atom,7,true}]],
>                                     [{call,
>                                          8,
>                                          {atom,8,throw},
>                                          [{tuple,
>                                               8,
>                                               [{atom,8,type_error},
>                                                {atom,8,id},
>                                                {tuple,
>                                                    9,
>                                                    [{atom,9,expected},
>                                                     {atom,9,not_null}]}]}]}]}]}, 
>                      {'if',8,
>                            [{clause,8,
>                                     [],
>                                     [[{call,
>                                           8,
>                                           {atom,8,is_integer},
>                                           [{var,8,'V_age'}]}]],
>                                     [{atom,8,true}]},
>                             {clause,9,
>                                     [],
>                                     [[{atom,9,true}]],
>                                     [{call,
>                                          10,
>                                          {atom,10,throw},
>                                          [{tuple,
>                                               10,
>                                               [{atom,10,type_error},
>                                                {atom,10,age},
>                                                {tuple,
>                                                    11,
>                                                    [{atom,11,expected},
>                                                     {atom,11,integer}]}]}]}]}]}, 
>                      {call,10,{atom,10,validate_oid},[{var,10,'V_id'}]},
>                      {call,11,{atom,11,validate_string},[{var,11,'V_name'}]},
>                      {'if',12,
>                            [{clause,12,
>                                     [],
>                                     [[{op,12,
>                                           '=<',
>                                           {integer,12,0},
>                                           {var,12,'V_age'}},
>                                       {op,12,
>                                           '=<',
>                                           {var,12,'V_age'},
>                                           {integer,12,100}}]],
>                                     [{atom,12,true}]},
>                             {clause,13,
>                                     [],
>                                     [[{atom,13,true}]],
>                                     [{call,
>                                          14,
>                                          {atom,14,throw},
>                                          [{tuple,
>                                               14,
>                                               [{atom,14,value_error},
>                                                {atom,14,age},
>                                                {tuple,
>                                                    15,
>                                                    [{atom,15,expected},
>                                                     {tuple,
>                                                         15,
>                                                         [{atom,15,inclusive},
>                                                          {integer,15,0},
>                                                          {integer,15,100}]}]}]}]}]}]}]}]}]
> ok
> (foo@REDACTED)94> compile:forms(v(92)).               
> .:none: internal error in beam_dead;
> crash reason: {{case_clause,{'EXIT',{function_clause,
>                                         [{dict,fetch_val,[5,[]]},
>                                          {beam_clean,find_all_used,3},
>                                          {beam_clean,module,2},
>                                          {beam_dead,module,2},
>                                          {compile,
>                                              '-select_passes/2-anonymous-2-',
>                                              2},
>                                          {compile,
>                                              '-internal_comp/4-anonymous-1-',
>                                              2},
>                                          {compile,fold_comp,3},
>                                          {compile,internal_comp,4}]}}},
>                [{compile,'-select_passes/2-anonymous-2-',2},
>                 {compile,'-internal_comp/4-anonymous-1-',2},
>                 {compile,fold_comp,3},
>                 {compile,internal_comp,4},
>                 {compile,internal,3}]}
> .:4: Warning: variable 'V_addr' is unused
> .:4: Warning: variable person is unused
> error
> 
> 

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list