Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Debugging child pid 4577 exit signal Segmentation fault (11)

by keenlearner (Acolyte)
on Sep 30, 2012 at 10:32 UTC ( #996493=perlquestion: print w/ replies, xml ) Need Help??
keenlearner has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am trying to debug these ambiguous error message generated in apache error_log. I am using mod_perl 2.

Sun Sep 30 18:16:59 2012 notice child pid 4577 exit signal Segmentation fault (11)

I have put debugging message in my code to know where this segmentation fault happen in between my debugging message then I can track which section of the code is causing this. However, this segmentation message always get printed at the last, after my code execution had finish. I think because of buffering, how can I get this segmentation message to get printed immediately ? I already set my debugging message to FH->autoflush(1). But how about this message generated by modperl ?

My code is too big to be shown here.

Thanks.

Comment on Debugging child pid 4577 exit signal Segmentation fault (11)
Re: Debugging child pid 4577 exit signal Segmentation fault (11)
by Anonymous Monk on Sep 30, 2012 at 10:41 UTC

      Hi,

      I don't know if it's a perl child.

      I have followed the apache core dump instruction from http://httpd.apache.org/dev/debugging.html#crashes

      I got the core dump

      dell:~ # gdb httpd2 /tmp/apache-cores/core

      (gdb) bt full #0 0x00007f43f5131320 in apr_palloc () from /usr/lib64/libapr-1.so.0 No symbol table info available. #1 0x00007f43f5129713 in apr_table_make () from /usr/lib64/libapr-1.so.0 No symbol table info available. #2 0x00007f43f5a173bd in ap_scan_script_header_err_core () No symbol table info available. #3 0x00007f43f5a1795e in ap_scan_script_header_err_strs () No symbol table info available. +#4 0x00007f43f002479a in modperl_cgi_header_parse () from /usr/lib64/apache2/mod_perl.so No symbol table info available. #5 0x00007f43ee639683 in XS_Apache2__RequestRec_send_cgi_header () fr +om /usr/lib/perl5/vendor_perl/5.14.2/x86_64-linux-thread-multi/auto/A +pache2/Response/Response.so No symbol table info available. #6 0x00007f43efd3bc8f in Perl_pp_entersub () from /usr/lib/perl5/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so No symbol table info available. #7 0x00007f43efd33126 in Perl_runops_standard () from /usr/lib/perl5/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so No symbol table info available. #8 0x00007f43efcceede in Perl_call_sv () from /usr/lib/perl5/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so No symbol table info available. #9 0x00007f43f0019725 in modperl_callback () from /usr/lib64/apache2/mod_perl.so No symbol table info available. #10 0x00007f43f0019f5c in modperl_callback_run_handlers () from /usr/lib64/apache2/mod_perl. +so No symbol table info available. #11 0x00007f43f001a49f in modperl_callback_per_dir () from /usr/lib64/apache2/mod_perl.so No symbol table info available. #12 0x00007f43f001490b in ?? () from /usr/lib64/apache2/mod_perl.so No symbol table info available. #13 0x00007f43f0014a82 in modperl_response_handler_cgi () from /usr/lib64/apache2/mod_perl.so No symbol table info available. #14 0x00007f43f5a11a88 in ap_run_handler () No symbol table info available. #15 0x00007f43f5a11f0e in ap_invoke_handler () No symbo +l table info available. #16 0x00007f43f5a1f7a0 in ap_process_request () No symbol table info available. #17 0x00007f43f5a1c5d8 in ?? () No symbol table info available. #18 0x00007f43f5a18518 in ap_run_process_connection () No symbol table info available. #19 0x00007f43f5a24340 in ?? () No symbol table info available. #20 0x00007f43f5a24aaa in ?? () No symbol table info available. #21 0x00007f43f5a24b67 in ?? () No symbol table info available. #22 0x00007f43f5a254e4 in ap_mpm_run () No symbol table info available +. #23 0x00007f43f59fc9aa in main () No symbol table info available. (gdb)

      But I still have no clue on what's wrong from the message, anyway to have a more clear one ? Thanks

Re: Debugging child pid 4577 exit signal Segmentation fault (11)
by keenlearner (Acolyte) on Sep 30, 2012 at 16:35 UTC

    The problem seem to be the persistent CGI object used in different requests, as described here http://osdir.com/ml/modperl.perl.apache.org/2009-02/msg00023.html
    However, I have use the "our $cgi = CGI->new;" , that should get initialized again in every request right ?

    (gdb) bt #0 0x00007f58e6621631 in XS_Apache2__RequestRec_send_cgi_header () from /usr/lib/perl5/vendor_perl/5.14.2/x86_64-linux-thread-multi/au +to/Apache2/Response/Response.so #1 0x00007f58e7d23c8f in Perl_pp_entersub () from /usr/lib/perl5/5.14 +.2/x86_64-linux-thread-multi/CORE/libperl.so #2 0x00007f58e7d1b126 in Perl_runops_standard () from /usr/lib/perl5/ +5.14.2/x86_64-linux-thread-multi/CORE/libperl.so #3 0x00007f58e7cb6ede in Perl_call_sv () from /usr/lib/perl5/5.14.2/x +86_64-linux-thread-multi/CORE/libperl.so #4 0x00007f58e8001725 in modperl_callback () from /usr/lib64/apache2/ +mod_perl.so #5 0x00007f58e8001f5c in modperl_callback_run_handlers () from /usr/l +ib64/apache2/mod_perl.so #6 0x00007f58e800249f in modperl_callback_per_dir () from /usr/lib64/ +apache2/mod_perl.so #7 0x00007f58e7ffc90b in ?? () from /usr/lib64/apache2/mod_perl.so #8 0x00007f58e7ffca82 in modperl_response_handler_cgi () from /usr/li +b64/apache2/mod_perl.so #9 0x00007f58ed9f9a88 in ap_run_handler () #10 0x00007f58ed9f9f0e in ap_invoke_handler () #11 0x00007f58eda077a0 in ap_process_request () #12 0x00007f58eda045d8 in ?? () #13 0x00007f58eda00518 in ap_run_process_connection () #14 0x00007f58eda0c340 in ?? () #15 0x00007f58eda0caaa in ?? () #16 0x00007f58eda0cb67 in ?? () #17 0x00007f58eda0d4e4 in ap_mpm_run () #18 0x00007f58ed9e49aa in main ()

      However, I have use the "our $cgi = CGI->new;" , that should get initialized again in every request right ?

      Um, maybe, if that line gets executed every time ...

Re: Debugging child pid 4577 exit signal Segmentation fault (11)
by Anonymous Monk on Oct 01, 2012 at 02:54 UTC

    CGI to mod_perl Porting. mod_perl Coding guidelines

    If the variable contains a reference it may hold onto lots of unecessary memory (or worse) if the reference is left to hang about until the next call to the same handler. For such variables you should use local so that the value is removed when the handler subroutine exits.

    my $query = CGI->new; becomes: local our $query = CGI->new;
      Hi, when I change the
      our $query = CGI->new;
      to
      local our $query = CGI->new;

      The $query var becomes undefined. the $query is a global variable in a module.

      I wonder why ?
Re: Debugging child pid 4577 exit signal Segmentation fault (11)
by Anonymous Monk on Oct 01, 2012 at 07:19 UTC

    Hi, finally found the culprit. I cannot use the string concatenation on the header function, I think it has to do with the prototype thingy. This is the line that cause error.

    return $cgi->header({-charset => "utf-8"}).$tmpl->output;

    the header has to be assigned to a variable first then concatenate. I still wonder why ?

    Thanks all.

      Ops...sorry, this is still causing the problem. After I refresh more time, still got segmentation fault. But definitely is this $cgi->header, cause if don't use this object but use print "Content-type: text/html\n\n", it's no longer causing the segfault.
      The final work around is putting the $cgi in the self.
      sub new { my ($class) = @_; my $self = {cgi => CGI->new}; bless $self, $class; return $self; }
        I still wonder why, I have been using the our $cgi = CGI->new for many modules, but only this particular module is having this issue. Any input will be great ?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://996493]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-12-21 15:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls