It seems as if I have a caused a deadlock somewhere either in my code or in code that I'm using, but I am not sure how to debug it. Since I have no clue where the problem is and I can make the system almost completely idle, I think that it would be useful to see a trace of all functions and messages leading up to the hang. It looks like dbg
provides some help in tracing, but I don't see how to configure it for such a broad trace. Is such a trace possible with dbg
or are there other ways of debugging hangs in Erlang that are better?
Asked
Active
Viewed 469 times
2

Frank Hunleth
- 720
- 4
- 13
-
What kind of application you are working on ? What is it doing before it hangs ? Do you have some sample code ? – Arunmu Jan 27 '14 at 07:44
-
The hang occurs in a cowboy-based application when I call application:stop/1. I was debating about posting more code, but my hope was to get a more generic answer for how people debug these issues rather than a specific solution to my current problem. – Frank Hunleth Jan 27 '14 at 16:49
2 Answers
1
I recommend using dbg
. While there is a conventional debugger as mentioned in another answer its usefulness is very limited for concurrent programs since it cause plenty of timeouts usually.
To overcome the hurdle of using dbg
I recommend the following resources:
All answers are interesting here but especially the user_default in the linked one helps also
Example what can be done by handling the trace messages yourself which can be useful in hard to debug cases.
Continuously updated links and nodes about Erlangs dbg
If you need to use dbg
in production I recommend using redbug which helps you not crash your node. Blogpost about using redbug

Community
- 1
- 1

Peer Stritzinger
- 8,232
- 2
- 30
- 43
0
Did you try the Erlang Debugger?

Tilman
- 2,015
- 14
- 16
-
I tried, but my setup doesn't seem ideal for it. My code runs on a remote node and I can't run the debugger locally on that node. I may just need to dig through the docs more since it seems like using the debugger on remote nodes would be possible in Erlang. I'll try after I work through the dbg recommendation. – Frank Hunleth Jan 28 '14 at 19:05