[Q] print all ruby thread stacks?

I am trying to debug a ruby program that periodically hangs when run
under jruby. It runs okay under MRI (1.8.7 and 1.9.1).

Is there a way for me to install a signal handler that prints all of the
thread callstacks and exits? This would help me pinpoint where in the
code it is hanging.

I was thinking something along the lines of this:

need to use ABRT since jruby doesn’t see a ctrl-c and I need to send

it

a kill -9 to exit

trap ‘ABRT’ do
@threads.each do |thread|
# print callstack?
end
end

I’d appreciate any help in this matter. Thank you…

cr


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

control-\ should dump all the stacks. Can that work or is this a daemon?

-Tom

On Sat, Mar 6, 2010 at 11:15 AM, Chuck R. [email protected]
wrote:

           # print callstack?

http://xircles.codehaus.org/manage_email


blog: http://blog.enebo.com twitter: tom_enebo
mail: [email protected]


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Mar 6, 2010, at 12:06 PM, Thomas E Enebo wrote:

need to use ABRT since jruby doesn’t see a ctrl-c and I need to send it

a kill -9 to exit

trap ‘ABRT’ do
@threads.each do |thread|
# print callstack?
end
end

I’d appreciate any help in this matter. Thank you…

I tried to interrupt it in the shell with control-\ but it is still
hung. The only way I can kill it is with a -9.

Maybe the entire interpreter is hanging. I’m kind of stuck and don’t
know how to interrupt its execution and still get any relevant data.

cr


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Mar 6, 2010, at 12:48 PM, Chuck R. wrote:

Is there a way for me to install a signal handler that prints all of the thread callstacks and exits? This would help me pinpoint where in the code it is hanging.

I’d appreciate any help in this matter. Thank you…

I tried to interrupt it in the shell with control-\ but it is still hung. The only way I can kill it is with a -9.

Maybe the entire interpreter is hanging. I’m kind of stuck and don’t know how to interrupt its execution and still get any relevant data.

I just tried attaching to the process using jvisualvm (this is on OSX
10.6.2 running JRuby 1.4.0 release and the 64-bit JVM).

Jvisualvm was unable to attach so I couldn’t do a thread dump or heap
dump. Something is getting majorly hosed here…

cr


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Running my code against 1.5.0-dev (head) never hangs. However, I do run
into that #map bug that I’ve written about in another thread. I now have
a little workaround for that so I can successfully run my code against
head.

Nevermind!

cr


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Kill -3 {pid} is another way of getting thread dumps.

Cheers,

James

On 6 Mar 2010 19:57, “Chuck R.” [email protected] wrote:

Running my code against 1.5.0-dev (head) never hangs. However, I do run
into
that #map bug that I’ve written about in another thread. I now have a
little
workaround for that so I can successfully run my code against head.

Nevermind!

cr

jruby-prof 0.1

This is a clone of ruby-prof for JRuby. It supports all the usual output
modes, plus a call tree output mode. The only measure mode it currently
supports is wall time.

*** NB. This is really new code. It probably has lots of bugs and
things. ***

I wrote a blog post about it here:
http://danlucraft.com/blog/2010/03/jruby-prof/

Please try it out and let me know if it doesn’t work for you!

INSTALL

$ jruby -S gem install jruby-prof

SOURCE

http://github.com/danlucraft/jruby-prof

USAGE

In your program:

require 'rubygems'
require 'jruby-prof'

result = JRubyProf.profile do
  # my stuff
end

JRubyProf.print_flat_text(result, "flat.txt")
JRubyProf.print_graph_text(result, "graph.txt")
JRubyProf.print_graph_html(result, "graph.html")
JRubyProf.print_call_tree(result, "call_tree.txt")
JRubyProf.print_tree_html(result, "call_tree.html")

In order to tell JRuby to send events to JRubyProf for processing, you
must
run your script with the debug flag on:

$ jruby --debug my_script.rb

Thanks,
Dan


Daniel L.

twitter.com/danlucraft
danlucraft.com/blog


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hot diggity! Finally a nice Ruby-land profiler for JRuby!

If this looks good to everyone, it might be a nice one to
pre-install…or not? Maybe we can just leave it as a gem in the wild
and people can install it if they want to?

On Sat, Mar 13, 2010 at 5:12 AM, Daniel L. [email protected]
wrote:

   # my stuff

- Daniel Lucraft


To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Mar 15, 2010, at 1:38 PM, Charles Oliver N. wrote:

Hot diggity! Finally a nice Ruby-land profiler for JRuby!

If this looks good to everyone, it might be a nice one to
pre-install…or not? Maybe we can just leave it as a gem in the wild
and people can install it if they want to?

I always prefer non-core stuff as a gem.

My 0.02

cr


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email