Skip to main content

Stack traces and deadlocks

3 replies [Last post]
lamsap
Offline
Joined: 2004-11-09
Points: 0

Hi,

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?

Thanks,

Mike

Reply viewing options

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

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.

http://wiki.java.net/twiki/bin/view/Mobileandembedded/PhoneMEAdvanced#Ti...

Chris

tonya_rae_moore
Offline
Administrator
Joined: 2011-05-20
Points: 0

 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 communitymanager@java.net if the information on that twiki needs to be exported to an updated java.net project.

 

Thank you.

lamsap
Offline
Joined: 2004-11-09
Points: 0

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: http://weblogs.java.net/blog/mlam/archive/2007/06/async_thread_du.html