Skip to main content

Stack traces and deadlocks

3 replies [Last post]
Joined: 2004-11-09


I'm running phoneME advanced b167 on linux-x86. Occasionally our application code deadlocks, and while we have code to print out names of all active threads, what we really would like to do is dump stack traces (we often find the problems through code review, but having stack traces would quickly narrow it down). I don't think I can use gdb as the network link to them is slow and unreliable.

In cdc/src/share/javavm/runtime/utils.c there is CVMdumpAllThreads which looks like it does exactly what I want. However it's not declared in utils.h, so I'm unsure if it would be "safe enough" for outside code to call? The only time I need to dump all thread stack traces is when there is a deadlock somewhere - where the system is already in a badly behaving state so any problems CVMdumpAllThreads may cause wouldn't be the end of the world.

Is using CVMdumpAllThreads the best approach? The app has a CLI that runs in a separate thread from the core functionality, so was planning on providing the ability to dump threads using that. I presume I would need to write a JNI method to invoke it, unless someone knows a way currently to invoke it within a Java app?

Ideally I would prefer the Java SE way with kill -QUIT generating stack traces. Any reason why I couldn't change the SIGQUIT handling code to invoke CVMdumpAllThreads when CVM_DEBUG is enabled?

Any other alternatives that I should be considering?



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-10-16

Use a CVM_INPSECTOR=true build and play around with cvmsh, the VMInspector java APIs, or calling some of the C APIs directly from C for gdb.


Joined: 2011-05-20

 I wanted to point out that, as the warning at the top of that page says, that twiki will be permanently deleted soon.  Please email if the information on that twiki needs to be exported to an updated project.


Thank you.

Joined: 2004-11-09

That's exactly what I was looking for, many thanks. The wiki also lead onto Mark's blog post about adding thread dumps to kill -QUIT too: