Perrin,
Thanks - as soon as I read what you said, I looked at the code and saw I
instantiated a CGI object at the top of the script, package-scoped so I
wouldn't have to pass it between subroutines. I thought I would test
this intuition by instantiating in the method that needed it, and pass
it to the subroutines that need it. Which worked, no more segfault.
The arrangement was basically:
#!/usr/bin/perl
use strict;
use CGI qw(:common);
...
my $webapp= new WebApp();
my $cgi= new CGI;
....
main();
...
sub main {
...
my $form= $cgi->Vars();
$user= $webapp->getForm();
someform($user, $form, $cgi);
}
sub someform {
my ($user, $form, $cgi= @_;
...
print $cgi->header('text/html') <-- segfault
...
}
It dawned on me as soon as I read the top sentence you wrote -- try
making $cgi lexical, and pass to someform() (arbitrary name). Problem solved
So now
#!/usr/bin/perl
...
use CGI qw(:standard);
my $webapp= new WebApp();
....
main()
sub main {
my $cgi= new CGI;
my $form = $cgi->Vars;
my $user= $webapp->getUser();
someform($user, $form, $cgi);
}
sub someform {
...
print $cgi->header('text/html'); <-- no more segfaults
}
So, this makes a good case for something that worked fine for CGI
(because no persistence) but in mod perl caused a problem due to a
package-scope CGI vs. lexical, a change that would have to be made from
going from CGI to ModPerl::Registry.
Thanks!
Patrick
Perrin Harkins wrote:
On Tue, Feb 10, 2009 at 10:44 PM, Patrick Galbraith <p...@patg.net> wrote:
After looking at it in gdb, I noticed it has something to do with
Apache2::RequestRec, the header in particular.
My guess is that you're keeping an old CGI or $r object around between
requests, or that this is some kind of special scenario where CGI.pm's
reset_globals is not being called.
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.
That also fits with my guess. Want to show us how you initialize your
$cgi object?
- Perrin