[erlang-bugs] escript: interesting stack trace

Tuncer Ayaz <>
Wed Feb 29 14:34:58 CET 2012


On Wed, Feb 1, 2012 at 6:59 PM, Tuncer Ayaz wrote:
> Running the following (simplified) erroneous piece of code as part
> of the rebar binary, a tiny escript, or erl shell gives mostly easy
> to follow stack traces.
>
> lists:append([{a,[b]},{c,[d]}]).
>
> I was only surprised to see win32reg:expand/1 on Linux and Darwin.
> Is this expected behaviour?
>
> The different stack traces are:
>
> as part of the rebar binary
> $ rebar compile
> {'EXIT',{badarg,[{erlang,memory,0,[]},
>                 {escript,run,2,[]},
>                 {escript,start,1,[]},
>                 {erlang,memory,0,[]}]}}
>
> on the erl shell
> $ erl
> 1> lists:append([{a,[b]},{c,[d]}]).
> ** exception error: bad argument
>     in function  erl_eval:do_apply/6
>     in call from shell:exprs/7
>     in call from shell:eval_exprs/7
>     in call from shell:eval_loop/3
>     in call from erlang:memory/0
>
> trivial escript
> $ cat append1.escript
> #!/usr/bin/env escript
> main(_) ->
>    lists:append([{a,[b]},{c,[d]}]).
> $ ./append1.escript
> escript: exception error: bad argument
>  in function  erl_eval:local_func/5
>  in call from escript:interpret/4
>  in call from escript:start/1
>  in call from win32reg:expand/1
>
> trivial escript in compile mode
> $ cat append2.escript
> #!/usr/bin/env escript
> -mode(compile).
> main(_) ->
>    lists:append([{a,[b]},{c,[d]}]).
> $ ./append2.escript
> escript: exception error: bad argument
>  in function  escript:run/2
>  in call from escript:start/1
>  in call from win32reg:expand/1

Seems to be fixed with otp.git OTP_R15B-415-gcc3122a (maint 15B01):

%% with non-native compiled escript.beam
$ ./append1.escript
escript: exception error: bad argument
  in function  erl_eval:local_func/5
  in call from prim_file:write/2
$ ./append2.escript
escript: exception error: bad argument
  in function  prim_file:write/2

%% with native compiled escript.beam
$ ./append1.escript
escript: exception error: bad argument
  in function  erl_eval:local_func/5
  in call from escript:interpret/4
  in call from escript:start/1
  in call from prim_file:write/2
$ ./append2.escript
escript: exception error: bad argument
  in function  escript:run/2
  in call from escript:start/1
  in call from prim_file:write/2


More information about the erlang-bugs mailing list