[erlang-bugs] escript: interesting stack trace

Tuncer Ayaz <>
Wed Feb 1 18:59:51 CET 2012


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


More information about the erlang-bugs mailing list