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

Dear Brains,

I have been using the WWW::Mechanize::Firefox module on my local machine with no complaint.

Recently I tried transferring it onto my VPS. So I made sure firefox and the MozRepl extension were installed and started both through x11 (connection speed slow but no problems to speak of). Then I attempted to run the following test script:

#!/usr/bin/perl use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new(); $mech->get('http://www.google.com');

Not complex! However, the result is:

MozRepl: Accepted Connection. Segmentation fault

At first I thought it might be a simple case of not enough memory, since my VPS only has 256 MB, but free -m gives me

total used free shared buffers cac +hed Mem: 256 226 29 0 20 +131 -/+ buffers/cache: 74 181 Swap: 255 56 199

In fact the used=226 is an illusion here (I think) as that figure includes the cache. I think the 74 is the actual program usage which is not that much. Further analysis with ps supports this idea - I couldn't get actual program usage to add up to more than 100 MB however I calculated it.

Next I tried running the program under gdb

Starting program: /usr/bin/perl ./testone.pl [Thread debugging using libthread_db enabled] MozRepl: Accepted connection. Program received signal SIGSEGV, Segmentation fault. 0x45978062 in ?? () from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/ +CORE/libperl.so (gdb) bt #0 0x45978062 in ?? () from /usr/lib/perl5/5.8.8/i386-linux-thread-mu +lti/CORE/libperl.so #1 0x459791d5 in ?? () from /usr/lib/perl5/5.8.8/i386-linux-thread-mu +lti/CORE/libperl.so #2 0x4597ac29 in Perl_sv_bless () from /usr/lib/perl5/5.8.8/i386-linu +x-thread-multi/CORE/libperl.so #3 0x4599ac3c in Perl_pp_bless () from /usr/lib/perl5/5.8.8/i386-linu +x-thread-multi/CORE/libperl.so #4 0x4596e98f in Perl_runops_standard () from /usr/lib/perl5/5.8.8/i3 +86-linux-thread-multi/CORE/libperl.so #5 0x4590f03e in ?? () from /usr/lib/perl5/5.8.8/i386-linux-thread-mu +lti/CORE/libperl.so #6 0x45913906 in Perl_call_sv () from /usr/lib/perl5/5.8.8/i386-linux +-thread-multi/CORE/libperl.so #7 0x4597a0e4 in Perl_sv_clear () from /usr/lib/perl5/5.8.8/i386-linu +x-thread-multi/CORE/libperl.so #8 0x4597a945 in Perl_sv_free () from /usr/lib/perl5/5.8.8/i386-linux +-thread-multi/CORE/libperl.so #9 0x4597aeee in ?? () from /usr/lib/perl5/5.8.8/i386-linux-thread-mu +lti/CORE/libperl.so #10 0x45977d10 in ?? () from /usr/lib/perl5/5.8.8/i386-linux-thread-mu +lti/CORE/libperl.so #11 0x45977d7a in Perl_sv_clean_objs () from /usr/lib/perl5/5.8.8/i386 +-linux-thread-multi/CORE/libperl.so #12 0x4591593b in perl_destruct () from /usr/lib/perl5/5.8.8/i386-linu +x-thread-multi/CORE/libperl.so #13 0x080491c7 in main () (gdb)

And looking at the core dump:

(gdb) core core.30048 warning: core file may not match specified executable file. Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE +/libperl.so...(no debugging symbols found)...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/l +ibperl.so Reading symbols from /lib/libresolv.so.2...(no debugging symbols found +)...done. Loaded symbols for /lib/libresolv.so.2 Reading symbols from /lib/libnsl.so.1...(no debugging symbols found).. +.done. Loaded symbols for /lib/libnsl.so.1 Reading symbols from /lib/libdl.so.2...(no debugging symbols found)... +done. Loaded symbols for /lib/libdl.so.2 Reading symbols from /lib/libm.so.6...(no debugging symbols found)...d +one. Loaded symbols for /lib/libm.so.6 Reading symbols from /lib/libcrypt.so.1...(no debugging symbols found) +...done. Loaded symbols for /lib/libcrypt.so.1 Reading symbols from /lib/libutil.so.1...(no debugging symbols found). +..done. Loaded symbols for /lib/libutil.so.1 Reading symbols from /lib/libpthread.so.0...(no debugging symbols foun +d)...done. Loaded symbols for /lib/libpthread.so.0 Reading symbols from /lib/libc.so.6...(no debugging symbols found)...d +one. Loaded symbols for /lib/libc.so.6 Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found) +...done. Loaded symbols for /lib/ld-linux.so.2 Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/Time/HiRes/HiRes.so...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/T +ime/HiRes/HiRes.so Reading symbols from /lib/i686/nosegneg/librt.so.1...(no debugging sym +bols found)...done. Loaded symbols for /lib/i686/nosegneg/librt.so.1 Reading symbols from /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread- +multi/auto/JSON/XS/XS.so...done. Loaded symbols for /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-mu +lti/auto/JSON/XS/XS.so Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/List/Util/Util.so...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/L +ist/Util/Util.so Reading symbols from /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread- +multi/auto/Params/Util/Util.so...done. Loaded symbols for /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-mu +lti/auto/Params/Util/Util.so Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/Cwd/Cwd.so...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/C +wd/Cwd.so Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/IO/IO.so...(no debugging symbols found)...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/I +O/IO.so Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/Fcntl/Fcntl.so...(no debugging symbols found)...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/F +cntl/Fcntl.so Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/Storable/Storable.so...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/S +torable/Storable.so Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/MIME/Base64/Base64.so...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/M +IME/Base64/Base64.so Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/Encode/Encode.so...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/E +ncode/Encode.so Reading symbols from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto +/Socket/Socket.so...(no debugging symbols found)...done. Loaded symbols for /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/S +ocket/Socket.so Reading symbols from /lib/libnss_files.so.2...(no debugging symbols fo +und)...done. Loaded symbols for /lib/libnss_files.so.2 Reading symbols from /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread- +multi/auto/Template/Stash/XS/XS.so...done. Loaded symbols for /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-mu +lti/auto/Template/Stash/XS/XS.so Core was generated by `/usr/bin/perl ./testone.pl'. Program terminated with signal 11, Segmentation fault. #0 0x45978062 in ?? () from /usr/lib/perl5/5.8.8/i386-linux-thread-mu +lti/CORE/libperl.so

But this is really not meaning much to me! So does anyone have any suggestions about interpreting this/what the problem might be/what to try next?

Replies are listed 'Best First'.
really no-one has any suggestions?
by tomgracey (Scribe) on Nov 24, 2010 at 05:37 UTC

    I realise this *might* be an operating system/memory issue but at the end of the day it is perl code that is throwing up the error.

    I am still stumped. Please help me. *sob*

      tomgracey:

      From a casual perusal of the stack dump, it looks like the segfault occurs during cleanup after your code runs. Possibly some things are freed out of order by the libraries and it may not be a serious problem for you. Have you tried putting in some code that does something after the get to see if it works as you expect it to? If everything works and it's just a cleanup bug at the end, you may be able suffer with it (i.e. code your app, report the cleanup bug to the appropriate parties, etc.)

      ...roboticus

        Ah yes...!

        Now I see the trap I fell into. My original code indeed had things after the get - it was supposed to write to a file.

        I was led astray by the fact the file wasn't generated by the original code. i assumed this went in hand with the segfault. However now I look without blinkers I see it is a permission error preventing the write. ie with tweaking it does in fact run to completion as you suggest.

        I never generated a segfault before and it frightened me...

        So you are saying I found a bug and this is NOT MY FAULT? Seriously never happened before..!

        roboticus - big hat off to you. Great diagnosis, very impressive!