renodino has asked for the wisdom of the Perl Monks concerning the following question:

I'm seeking a tool to extract the stack(s) from a coredump of a (multithreaded) Perl application. CPAN turned up Devel::CoreStack but its 10 years old, and likely isn't going to be up to date with Perl 5.8 and/or ithreads. I also found the (very helpful, but not neccesarily for this issue) node Techniques for isolating bugs in perl.

My problem relates to a large scale multithreaded Perl app running on Linux (RHAS4, perl 5.8.7). (FWIW: Its sortof like a web server, but for other protocols.) After 16-20 hours of moderate use, one of the threads hangs in a 100% CPU loop. My hope was I could force a coredump, and then use a tool (like Devel::CoreStack) that could easily locate the stacks of each thread, and I could see where all the threads are executing at the coredump.

I was hoping to avoid the overhead of running with -d if possible, tho the method described by Re: Techniques for isolating bugs in perl may be one solution.

Is there a more current version of Devel::CoreStack (or equivalent) available ?

Update:
After some reflection, I think I've got a reasonable solution derived from Devel::DProf + IPC::ShareLite Sys::Mmap. Basically, I'll create a ring buffer in shared memory an mmap'ed file, 1 ring per thread, w/ fixed size slots to which I store "sprintf package::method::line timestamp" package, sub, line number, and timestamp in DB::DB, then use an external script to view the ring buffers while the profiled app is running.

Is there a module that already does this ? Everything I found just saved a big buffer and dumped it to a file at exit. Assuming there isn't such a module, does anyone have any recommendations for a namespace ? Current working title is "Devel::MmapProf", but I'm thinking "Devel::STrace" may make more sense, since thats essentially what the module does - strace for perl apps.

Update 2:
Done. See Devel::STrace and Devel::STrace: strace for Perl scripts (with some seedlings) for details.

Replies are listed 'Best First'.
Re: Perl coredump analysis tool ?
by planetscape (Chancellor) on Apr 01, 2006 at 21:11 UTC
Re: Perl coredump analysis tool ?
by hv (Prior) on Apr 01, 2006 at 19:29 UTC

    I'm not sure how good gdb is at examining multiple threads, but I've usefully debugged hanging perl scripts in the past by attaching to them with gdb -p. Maybe that'd be a useful starting point for you.

    Hugo

Re: Perl coredump analysis tool ?
by moklevat (Priest) on Apr 01, 2006 at 21:21 UTC
    It seems your timing could not be better. The most esteemed TimToady just posted information about the Bugs Manifesto.

    moklevat tried to resist the temptation to post this, but failed.

    moklevat thinks he may have just written a good sig...or perhaps epitaph.