exiting with badarg && Erlang Web server

Ulf Wiger ulf.wiger@REDACTED
Mon Jun 14 11:38:41 CEST 1999

Francesco Cesarini wrote:
> The only bad arg I can see occur here (You unfortunately provided too
> little of the code) is if you are attempting to send a message to a
> registered process which does not exist.
> * Has chat_server been started, and has the process been registered?
> * If you have spawned a process, has it crashed? (These suckers tend to
> die silently.)

They die silently if they have been started with spawn(M,F,A).
This is a feature, BTW, since clear error reporting *is* a bit

There are ways to get more error reports from process termination:

1. Use spawn_link(M,F,A) instead of spawn/3.
In this case the parent process will receive a message, {'EXIT',
Reason}, when the child process dies. If the parent doesn't trap exits,
it'll die and you'll probably notice.


$> erl -boot start_clean
Erlang (BEAM) emulator version
Eshell V4.8.2.1  (abort with ^G)
1> spawn_link(foo,bar,[]).
** exited: {undef,{foo,bar,[]}} **

2. Use the proc_lib equivalents to spawn/3 and spawn_link/3.
The module proc_lib will do the same thing as spawn/3 and spawn_link/3,
but will trap its own exits and generate an error report before exiting.
To see the crash reports, you must start SASL (unless you have your own
error reporting mechanism.)


(No error reporting if you don't start SASL)

etxuwig@REDACTED > erl -boot start_clean
Erlang (BEAM) emulator version
Eshell V4.8.2.1  (abort with ^G)
1> proc_lib:spawn(foo,bar,[]).

(Progress, Error and Crash reports with SASL)

$ > erl -boot start_sasl
=PROGRESS REPORT==== 14-Jun-1999::11:30:22 ===
         application: sasl
          started_at: nonode@REDACTED
1> proc_lib:spawn(foo,bar,[]).
=CRASH REPORT==== 14-Jun-1999::11:30:35 ===
    pid: <0.39.0>
    registered_name: []
    error_info: {undef,{foo,bar,[]}}
    initial_call: {foo,bar,[]}
    ancestors: [<0.25.0>]
    messages: []
    links: []
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 233
    stack_size: 0
    reductions: 74

Ulf Wiger, Chief Designer AXD 301     <ulf.wiger@REDACTED>
Ericsson Telecom AB                          tfn: +46  8 719 81 95
Varuvägen 9, Älvsjö                          mob: +46 70 519 81 95
S-126 25 Stockholm, Sweden                   fax: +46  8 719 43 44

More information about the erlang-questions mailing list