[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Debugging endless loops

Alexey Verkhovsky

1/22/2006 6:05:00 PM

Hi all,

Say, we have a Ruby app going into an endless loop (or perhaps a thread
deadlock) mode. Let us further assume that it happens in production and
you don't know how to reproduce it anywhere else. How would you debug this?

Debugging these conditions in Java is trivial because of the "thread
dump" feature of JVM (where you send a kill -3 signal to a JVM process
and it spits out stack tracces of all threads to stdout). In any
environemnt where you can attach a debugger to a running app, it is not
heinously difficult either (although it may be problematic to attach a
debugger to a productiuon environment).

But what do I do if it's Ruby?

Alex Verkhovsky


10 Answers

Eero Saynatkari

1/22/2006 8:09:00 PM

0

Alexey Verkhovsky wrote:
> Hi all,
>
> Say, we have a Ruby app going into an endless loop (or perhaps a thread
> deadlock) mode. Let us further assume that it happens in production and
> you don't know how to reproduce it anywhere else. How would you debug
> this?
>
> Debugging these conditions in Java is trivial because of the "thread
> dump" feature of JVM (where you send a kill -3 signal to a JVM process
> and it spits out stack tracces of all threads to stdout). In any
> environemnt where you can attach a debugger to a running app, it is not
> heinously difficult either (although it may be problematic to attach a
> debugger to a productiuon environment).
>
> But what do I do if it's Ruby?

Can you do ruby -rdebug program.rb instead of running it normally?

> Alex Verkhovsky


E


--
Posted via http://www.ruby-....


Florian Groß

1/22/2006 9:25:00 PM

0

Alexey Verkhovsky

1/22/2006 10:45:00 PM

0

Eero Saynatkari wrote:

>>Say, we have a Ruby app going into an endless loop (or perhaps a thread
>>deadlock) mode. Let us further assume that it happens in production and
>>you don't know how to reproduce it anywhere else. How would you debug
>>this?
>>
>>
>Can you do ruby -rdebug program.rb instead of running it normally?
>
>
By the conditions of our imaginary problem, we only reproduce our
endless loop in the production environment, and -rdebug makes a typical
Ruby code two orders of magnitude slower, so this wouldn't do.

Florian Groß wrote:
> This might work and give you a remote debugging back door. I'm just
not sure if it will survive deadlocks:
> require 'breakpoint'
...
> You can then connect to your application with breakpoint_client.

Hi, Florian,
Remote 'breakpointer' might be a workable idea. But when I am in IRB,
how do I get stack traces for all currently running threads?
Rest assured, I do know where to find 'breakpoint' library - I keep
telling about it to everyone pissed off or puzzled by the absence of a
decent debugger in the Ruby world.

Alex


Florian Groß

1/22/2006 11:07:00 PM

0

Alexey Verkhovsky

1/22/2006 11:23:00 PM

0

Florian Groß wrote:

> I really think that Thread#caller would be a good idea...

As well as a thread dump default signal handler on "kill -3". In some
circumstances, this Java feature is just priceless.

Alex



John Carter

1/23/2006 3:19:00 AM

0

Alexey Verkhovsky

1/23/2006 4:46:00 AM

0

John Carter wrote:

>> Say, we have a Ruby app going into an endless loop (or perhaps a
>> thread deadlock) mode. Let us further assume that it happens in
>> production and you don't know how to reproduce it anywhere else. How
>> would you debug this?
>
> Thread.abort_on_exception = true

Neither endless loop, nor deadlock are exception conditions.

Alex


Robert Klemme

1/23/2006 8:43:00 AM

0

Alexey Verkhovsky wrote:
> Hi all,
>
> Say, we have a Ruby app going into an endless loop (or perhaps a
> thread deadlock) mode. Let us further assume that it happens in
> production and you don't know how to reproduce it anywhere else. How
> would you debug this?
>
> Debugging these conditions in Java is trivial because of the "thread
> dump" feature of JVM (where you send a kill -3 signal to a JVM process
> and it spits out stack tracces of all threads to stdout). In any
> environemnt where you can attach a debugger to a running app, it is
> not heinously difficult either (although it may be problematic to
> attach a debugger to a productiuon environment).
>
> But what do I do if it's Ruby?

You can write a singnal handler that outputs current thread states.
set_trace_func may help here also.

Kind regards

robert

John Carter

1/23/2006 7:55:00 PM

0

Stephen Kellett

1/23/2006 11:33:00 PM

0

In message <43D3C973.1010306@verk.info>, Alexey Verkhovsky
<alex@verk.info> writes
>But what do I do if it's Ruby?

What about a flow tracer?

Ruby Bug Validator. http://www.software...

Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk/sof...
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting