I have tried to debug(using perl -d <script-name>) the script, but the debugger does not comeup or no response when it lands on statement to create thread(threads->create(...)), i had to wait long time but i did not comeup so i have to kill the process.
I cannot post the whole code, because it is big and uses some of private packages, but here is how i create 10 threads for each project.
The script terminates by printing Segmentation fault, after executing last print statement in _replicate function. I not able to make out where and why that error is occuring. Or is there a other way to achieve parallel processing withoug using threads? Could someone help me here please?
I am using perl, v5.8.3 built for x86_64-linux-thread-multi
sub _replicate{ my $ref = shift; my $logger = get_logger(); print "Starting replication of dependency files", $/; foreach my $sc(@{$ref}){ next unless (defined $sc); mkdir($LOG_FOLDER."/".$sc->{sc_name}); print "\tScenario: ".$sc->{sc_name}, $/; print "\tLatest Dependencies: ".$sc->{total_dep}." of size "._ +get_readable_size($sc->{total_size}), $/; my @thr_arr = (); print "Creating parallel threads", $/; foreach my $robj(@{$sc->{rsync}}){ my $th = threads->create(\&worker, $robj); # i create thre +ads this way push @thr_arr, $th; } #$logger->info("\twaiting for threads to finish its job..."); print "\twaiting for threads to finish its job...", $/; foreach my $t(@thr_arr){ if (defined $t){ my $k = $t->join(); # this is how i wait for all thre +ads to finish } } #map {my $k = $_->join} threads->list; # map{ # my $th = $_; # my $k = $th->join if($th); # just a blind belief +whether this might cause 'Segmentation fault', hence the check. # }@thr_arr; #$logger->info("\tFinished replicating dependencies of ".$sc-> +{sc_name}); print "\tFinished replicating dependencies of ".$sc->{sc_name} +, $/; } } sub worker{ my $robj = shift; my ($rsync, $server, $from, $to) = @{$robj->{elements}}; my $alt_server = $RSYNC_CONN_STR_2; my $rsync_cmd = $rsync.$server.$from.$to; print "Thread-",threads->self->tid," executing ", $rsync_cmd; }
Thanks in advance,
katharnakh.
In reply to Segmentation fault: problem with perl threads by katharnakh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |