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

I have a Perl/Tk app that's crashing with a segfault, presumably because some C code inside Perl/Tk is dereferencing a null pointer or something like that. The crashes are infrequent and hard to reproduce. After waiting patiently for a long time, I managed to capture a core dump. However, is there anything useful I can do with the core dump? I'm just using the binary distro of Perl/Tk that comes with the latest Ubuntu, which I presume wasn't compiled with debugging symbols. I could compile Perl/Tk from source with debugging info, but I'm not even sure that would help. The syntax for gdb in this situation would seem to be 'gdb app core', where app is, I think, supposed to be an ELF executable, not a Perl script that happens to call some C code via XS. Any suggestions on how to approach this?

TIA!

  • Comment on using a core file from a crash in someone else's XS?

Replies are listed 'Best First'.
Re: using a core file from a crash in someone else's XS?
by samtregar (Abbot) on Nov 02, 2005 at 20:21 UTC
    Yes, you can use a core file with GDB. The app to feed to GDB in this case is Perl itself, ex: /usr/bin/perl. This will produce much more useful results in many cases if you compiled your Perl and your XS modules with debugging symbols.

    I've found that although GDB can rarely tell me what cased a seg-fault it can sometimes point the way to the right area of code to look at. Sometimes that's the only hint you need.

    -sam

      Aha! Thanks, that helped a lot. Now I know it's crashing in a routine called Tk_HandleEvent() inside Perl/Tk, which is a lot more than I knew before!