Hello all,

I'm writing about the benefits of mod_perl in my book, having taken a CGI script and using ModPerl::Registry turning it into a mod_perl app... so on so forth... While testing what I'm writing about, I keep seeing segfaults in my apache log. I started worrying that I have a bug in DBD::mysql that I need to get fixing that I somehow missed in the fog of writing a book the past 10 months, but found it had nothing to do with that at all.

After looking at it in gdb, I noticed it has something to do with Apache2::RequestRec, the header in particular.

I had a hunch, so I changed:

print $cgi->header('text/html');

To

print "Content-type: text/html\n\n";

Problem goes away. But a new problem manifests itself- the form parameters aren't showing up properly

I use the line: $vars= $cgi->Vars();

And then access form parameters as $vars->{param}...

Sometimes they submit correctly, other times they don't. I have a couple GET links and GET parameter parsing seems particularly erratic on cgi->header() is taken out.

Is there something that I missed in the docs? Are there any particular issues using CGI.pm with mod_perl that would be worth knowing about? I will say from the debug output, CGI.pm seems to utilize Apache2::RequestRec, which I was wondering about.


Also, this makes an interesting issue to include using $cgi->header() in the book when it causes a segfault.

Note- this segfaulting occurs on two completely different boxes, same fix applies.

Here's the output of the debugger:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47801312445536 (LWP 12196)]
0x00002b79a752c9f6 in XS_Apache2__RequestRec_send_cgi_header (my_perl=0x1d5c82a0, cv=<value optimized out>)
   at Response.xs:149
149        mpxs_Apache2__RequestRec_send_cgi_header(r, buffer);


....

(gdb) bt
#0 0x00002b79a752c9f6 in XS_Apache2__RequestRec_send_cgi_header (my_perl=0x1d5c82a0,
   cv=<value optimized out>) at Response.xs:149
#1  0x0000003971890996 in Perl_pp_entersub ()
  from /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
#2  0x000000397188a23e in Perl_runops_standard ()
  from /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
#3  0x00000039718375f0 in Perl_call_sv ()


(gdb) frame 0
#0 0x00002b79a752c9f6 in XS_Apache2__RequestRec_send_cgi_header (my_perl=0x1d5c82a0,
   cv=<value optimized out>) at Response.xs:149
149        mpxs_Apache2__RequestRec_send_cgi_header(r, buffer);
(gdb) list
144        Apache2::RequestRec r
145        SV * buffer
146 147 148 CODE:
149        mpxs_Apache2__RequestRec_send_cgi_header(r, buffer);
150 151 152 MODULE = Apache2::Response
153    PROTOTYPES: disabled

Reply via email to