http://qs321.pair.com?node_id=11108865

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

I'm working (as most of the time) with my preforking webserver. I'm running into an issue where sometimes (after minutes/hours/days) one of those preforked processes stops responding and hovering at 100% CPU load. Perl 5.30.1 in Ubuntu 18.04.

All i need is a nice Perl stacktrace so i can tell whats going on. Starting the debugger on the command line isn't really an option, because the process forks hundreds of times. I can't run anything that world fork a gazillion terminals because the problem only happens on a server, and doing potentially hundreds of xterms via X11 forwarding is just not going to finish before the heat death of the universe.

I've also tried App::Stacktrace and Enbugger, both of which don't work. Since i suspects that the bug is somewhere in my exception/error handling code, i'd rather not introduce extra exceptions or signal handling code anyway, but i want to stop my process and dump the stacktrace.

Does anyone know how to dump the stacktrace of the script (not the interpreter) with gdb?

Are there any alternative solutions?

Update: I managed to find the problem by implementing a poor mans stacktrace. I wrote a pair of scripts to add/remove a debug print at the beginning of every function. After i roughly found where the code went bad, i spent a couple of days doing a static analysis. As suspected, the problem was in the error handling code for a block eval. You can find the scripts here and here.

perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'