[Omaha.pm] Debugging running Perl code on Windows.

Hugh Jarce hjarce2001 at yahoo.com
Tue Sep 21 17:53:47 CDT 2004


Daniel Linder wrote:
> I'm trying to debug hung perl processes running on a Windows 2003 server.
> It is running the pre-compiled ActiveState perl, and the perl program
> runs once every five minutes processing e-mail from a remote POP3 server.
> 
> Occasionaly the perl interperter gets stuck and will wait forever.  Does
> anyone know of a way to hook into the running perl process under Windows
> to see what it is really waiting for?  If it helps, I'm using the Open
> Perl IDE (http://open-perl-ide.sourceforge.net/).  My last resort is to
> put a ton of debug logging into the script and let it run but I'd rather
> not add that overhead...

You might also try downloading various tools. For example, pslist
<http://www.sysinternals.com/ntw2k/freeware/pstools.shtml> will
tell you how many threads and what state they are in when the
process hangs, while handle
<http://www.sysinternals.com/ntw2k/freeware/handle.shtml> will tell
you you about the handles the process has open. Running pslist -d
should tell you about the state of all threads (e.g. Wait:UserReq) --
if they are all waiting, you have a deadlock. Alternatively, watching
the CPU time should tell you if the process has got stuck in an
infinite loop.

For intermittent hangs, you may need to break into a Windows debugger.
To do that, from the Windows Task Manager, right click on the hung process
and select Debug. Of course, for this to work you will need to have
installed a debugger; WinDbg (freely downloadable from Microsoft web site)
is a good one. If you are inexperienced in Windows C-level debugging,
there is a bit of a learning curve. In case it helps, here are some
useful WinDbg commands for tracking process deadlocks:
 ~* kv       stack trace of all threads in the process
 !locks      dump of locks
 !cs         dump of critical sections
For best results, recompile Perl from the ActiveState C sources.
Doing C-level debugging is a last resort, and Jay's excellent advice
of adding logging is worthwhile whether or not you go down that route.

BTW, is this a Intel hyper-threaded machine? This is a long shot,
but if you are running a hyper-threaded machine, you might try
upgrading the BIOS to the latest version (downloadable from Intel
web site). Early versions of hyper-threaded machines had some BIOS
bugs that could cause intermittent hangs.

Hugh.



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail


More information about the Omaha-pm mailing list