Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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=");'

In reply to Debugging forking perl script? GDB? by cavac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-24 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found