Subject: | SegFault with Perl thread + HTTP::Request on SMP(Linux kernal 2.4.21).) |
The following code will result in segmentation fault occasionally,
Show quoted text
------- code start --------
use strict;
use threads;
use HTTP::Request;
our $thread_num = 5;
our $msg_per_thread = 100;
our $thr_handler = sub{
my $thr_id = shift;
foreach my $id (1..$msg_per_thread){
my $req = HTTP::Request->new('GET', 'http://localhost.com');
$req->header(
'field1' => 'value1',
'field2' => 'value2',
);
print "$id. " . $req->as_string;
}
};
my @threads;
for(my $i=0; $i < $thread_num; $i++){
push @threads, threads->new($thr_handler, $i);
}
foreach my $thread (@threads){
$thread->join;
}
------- code end --------
But, the code will work fine without SMP on linux (Perl 5.8.5). Any idea or solution? Please help.
Thanks!
Regards,
KulikKu