Closed p5pRT closed 21 years ago
I am using LWP::UserAgent and CGI in a simple script and perl intermitantly seg faults\, and cores out. I have no more info than that.
Here is the script:
#!/usr/local/bin/perl -d:DProf
use CGI;
use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->agent("Bob/0.1 " . $ua->agent);
my @days = qw(Sun Mon Tue Wed Thu Fri Sat); my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my $dt;
$cgi = new CGI; my $url = $cgi->param('url');
($domain = $url) =~ s/.*?\.(.+)\..{2\,}$/$1/; my $path = $cgi->param('path');
if(-e "/cache/$domain/$path") { my @dt = localtime((stat("/cache/$domain/$path"))[9]); my $hr = $dt[2] - 7; $dt[1] =~ s/^(\d)$/0$1/; $dt[0] =~ s/^(\d)$/0$1/; $hr =~ s/^(\d)$/0$1/; $dt = $days[$dt[6]]."\, ".$dt[3]." ".$months[$dt[4]]." ". ($dt[5] + 1900) ." ". $hr .":".$dt[1].":".$dt[0]." GMT"; }
my $method = $cgi->request_method() || 'GET';
my $req = new HTTP::Request $method => "http://$url/$path";
#$req->header('If-Modified-Since' => 'Wed\, 26 May 1999 17:24:00 GMT'); print "$dt\n"; $req->header('If-Modified-Since' => $dt);
my $res = $ua->request($req);
foreach(keys(%{$res->headers})) { print "$_ => ".$res->headers->{$_}."\n"; } print $res->content;
I think the problem is in DProf but I haven't had time to investigate any further.
Can anyone duplicate this error? It happens once every 10 runs.
Here is the script:
#!/usr/local/bin/perl -d:DProf
use CGI;
use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->agent("Bob/0.1 " . $ua->agent);
my @days = qw(Sun Mon Tue Wed Thu Fri Sat); my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my $dt;
$cgi = new CGI; my $url = $cgi->param('url');
($domain = $url) =~ s/.*?\.(.+)\..{2\,}$/$1/; my $path = $cgi->param('path');
if(-e "/cache/$domain/$path") { my @dt = localtime((stat("/cache/$domain/$path"))[9]); my $hr = $dt[2] - 7; $dt[1] =~ s/^(\d)$/0$1/; $dt[0] =~ s/^(\d)$/0$1/; $hr =~ s/^(\d)$/0$1/; $dt = $days[$dt[6]]."\, ".$dt[3]." ".$months[$dt[4]]." ". ($dt[5] + 1900) ." ". $hr .":".$dt[1].":".$dt[0]." GMT"; }
my $method = $cgi->request_method() || 'GET';
my $req = new HTTP::Request $method => "http://$url/$path";
#$req->header('If-Modified-Since' => 'Wed\, 26 May 1999 17:24:00 GMT'); print "$dt\n"; $req->header('If-Modified-Since' => $dt);
my $res = $ua->request($req);
foreach(keys(%{$res->headers})) { print "$_ => ".$res->headers->{$_}."\n"; } print $res->content;
Migrated from rt.perl.org#3671 (status was 'resolved')
Searchable as RT3671$