# Thread dump?

**URL:** <https://www.ruby-forum.com/t/thread-dump/73203>\
**Category:** Ruby\
**Created:** [October 22, 2006, 9:06pm UTC](https://www.ruby-forum.com/t/thread-dump/73203 "2006-10-22T21:06:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 22, 2006, 9:06pm UTC](https://www.ruby-forum.com/t/thread-dump/73203/1 "2006-10-22T21:06:56Z")

</div>

Hi there, I have a process that seems to be stuck somewhere. Is there  
the possibility of doing a thread dump to show where it is hanging on?  
Cheers -  
Christian

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 22, 2006, 9:12pm UTC](https://www.ruby-forum.com/t/thread-dump/73203/2 "2006-10-22T21:12:56Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Hi there, I have a process that seems to be stuck somewhere. Is there  
> the possibility of doing a thread dump to show where it is hanging on?  
> Cheers -  
> Christian

Not in general, without a Thread#backtrace method. I’ve asked for it…

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/159482](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/159482)

As noted in that post, you can destructively find out where the thread  
is by calling #raise on it. Just make sure the thread has an exception  
handler somewhere to print out the exception and backtrace.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 15, 2006, 9:21pm UTC](https://www.ruby-forum.com/t/thread-dump/73203/3 "2006-11-15T21:21:41Z")

</div>

On Oct 22, 2006, at 12:12 PM, Joel VanderWerf wrote:

> [http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/159482](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/159482)
> 
> As noted in that post, you can destructively find out where the  
> thread is by calling #raise on it. Just make sure the thread has an  
> exception handler somewhere to print out the exception and backtrace.

$ ruby -e ‘t = Thread.start do sleep end; t.raise “hi”; t.value’  
-e:1: hi (RuntimeError)  
from -e:1:in `value’  
from -e:1

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 16, 2006, 8:51pm UTC](https://www.ruby-forum.com/t/thread-dump/73203/4 "2006-11-16T20:51:22Z")

</div>

On Nov 15, 2006, at 5:13 PM, Joel VanderWerf wrote:

> Eric H. wrote:
> 
> > $ ruby -e ‘t = Thread.start do sleep end; t.raise “hi”; t.value’  
> > -e:1: hi (RuntimeError)  
> > from -e:1:in `value’  
> > from -e:1
> 
> That doesn’t tell you what line of code the thread is sleeping on,  
> only what lines of code #raise and #value are called on. You lose  
> the whole backtrace, in fact.

Ooh, right, my bad.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 16, 2006, 2:14am UTC](https://www.ruby-forum.com/t/thread-dump/73203/5 "2006-11-16T02:14:23Z")

</div>

Eric H. wrote:

> > As noted in that post, you can destructively find out where the thread  
> > is by calling #raise on it. Just make sure the thread has an exception  
> > handler somewhere to print out the exception and backtrace.
> 
> $ ruby -e ‘t = Thread.start do sleep end; t.raise “hi”; t.value’  
> -e:1: hi (RuntimeError)  
> from -e:1:in `value’  
> from -e:1

That doesn’t tell you what line of code the thread is sleeping on, only  
what lines of code #raise and #value are called on. You lose the whole  
backtrace, in fact.

$ cat th.rb  
t = Thread.start do  
sleep  
end

t.raise “hi”  
t.value

$ ruby th.rb  
th.rb:5: hi (RuntimeError)  
from th.rb:6:in `value’  
from th.rb:6
