[erlang-questions] finding deadlocks (Re: eep: multiple patterns)
Ulf Wiger (TN/EAB)
Fri May 30 23:06:25 CEST 2008
Raoul Duke skrev:
>> %% Special case for HCMSG_RELEASE to avoid deadlock
> super newbie question: in general, how do folks approach finding and
> fixing deadlock issues in Erlang?
> thanks. :)
We're straying from the multiple patterns thread,
so I changed the subject.
There are different kinds of deadlock.
One trivial form of deadlock in erlang is when
two processes call each other synchronously at the same
time. The nice way to try to avoid this is of course
to strive to only allow synchronous calls in one
direction. The low-level safety is to use gen_server:call()
and avoid using timeout 'infinity'. This way, at least
you will get a timeout and a crash report, alerting you of
Programming entirely asynchronously, deadlocks can still
occur, but are harder to detect. Finding such deadlocks
is easier if transient states are signified by the name
of the function. Then, a process listing can help,
looking at the current function.
If a process is blocked in a receive clause, and it's
not clear what it's waiting for, sometimes a stack
trace (process_info(Pid, backtrace)) can help, but it's
a bit messy.
More information about the erlang-questions