I am working on a perl app that uses multiple threads to handle multiple instances of the same sub routine. During testing, I have run into an issue with segfaults after the first thread is created and the sub routines have started to process. During the creation of the second thread is where I run into the segfault.
Any help with this is greatly appreciated. It is frustrating as hell.
Here is the code that I use to create the threads.
use Lib:LSInstance;
use Lib:LSParse qw(parseMain);
use Lib:aemon;
use Data:umper;
use strict;
use threads;
#Lib:aemon::daemonize();
my @thisVar = Lib:LSInstance::getInstances();
for(my $i = 0; $i < @thisVar; $i++){
my $thr1 = threads->new(\&threadTest, $thisVar[$i][2],$thisVar[$i][1] )->join();
}
sub threadTest{
print "Child Thread $_[0] \n";
print "********************************************************************************\n";
my @thatVar = parseMain($_[0],$_[1]);
#print Dumper(@thatVar);
}
And here is what I get with a stack trace after the first thread has been started.
) = 0
stat64("/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0x9d51270) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.8/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.7/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.6/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.5/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.8/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.7/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.6/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.5/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/5.8.8/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("./auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
close(3) = 0
munmap(0xb7cba000, 135168) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
_llseek(0, 0, 0xbf91ff20, SEEK_CUR) = -1 ESPIPE (Illegal seek)
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
_llseek(1, 0, 0xbf91ff20, SEEK_CUR) = -1 ESPIPE (Illegal seek)
ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
_llseek(2, 0, 0xbf91ff20, SEEK_CUR) = -1 ESPIPE (Illegal seek)
ioctl(6, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbf91fef8) = -1 ENOTTY (Inappropriate ioctl for device)
_llseek(6, 0, [6019], SEEK_CUR) = 0
mmap2(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7238000
munmap(0xb7238000, 528384) = 0
clone(Child Thread HS_INT2_BASE
********************************************************************************
child_stack=0xb7cb94b4, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0xb7cb9bd8, {entry_number:6, base_addr:0xb7cb9b90, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}, child_tidptr=0xb7cb9bd8) = 4146
futex(0xb7cb9bd8, FUTEX_WAIT, 4146, NULL <unfinished ...>
+++ killed by SIGSEGV +++
Any help with this is greatly appreciated. It is frustrating as hell.
Here is the code that I use to create the threads.
use Lib:LSInstance;
use Lib:LSParse qw(parseMain);
use Lib:aemon;
use Data:umper;
use strict;
use threads;
#Lib:aemon::daemonize();
my @thisVar = Lib:LSInstance::getInstances();
for(my $i = 0; $i < @thisVar; $i++){
my $thr1 = threads->new(\&threadTest, $thisVar[$i][2],$thisVar[$i][1] )->join();
}
sub threadTest{
print "Child Thread $_[0] \n";
print "********************************************************************************\n";
my @thatVar = parseMain($_[0],$_[1]);
#print Dumper(@thatVar);
}
And here is what I get with a stack trace after the first thread has been started.
) = 0
stat64("/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0x9d51270) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.8/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.7/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.6/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/5.8.5/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/site_perl/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.8/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.7/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.6/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/5.8.5/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/vendor_perl/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/perl5/5.8.8/auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
stat64("./auto/DBI/DESTROY.al", 0xbf91fb6c) = -1 ENOENT (No such file or directory)
close(3) = 0
munmap(0xb7cba000, 135168) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
_llseek(0, 0, 0xbf91ff20, SEEK_CUR) = -1 ESPIPE (Illegal seek)
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
_llseek(1, 0, 0xbf91ff20, SEEK_CUR) = -1 ESPIPE (Illegal seek)
ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
_llseek(2, 0, 0xbf91ff20, SEEK_CUR) = -1 ESPIPE (Illegal seek)
ioctl(6, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbf91fef8) = -1 ENOTTY (Inappropriate ioctl for device)
_llseek(6, 0, [6019], SEEK_CUR) = 0
mmap2(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7238000
munmap(0xb7238000, 528384) = 0
clone(Child Thread HS_INT2_BASE
********************************************************************************
child_stack=0xb7cb94b4, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0xb7cb9bd8, {entry_number:6, base_addr:0xb7cb9b90, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}, child_tidptr=0xb7cb9bd8) = 4146
futex(0xb7cb9bd8, FUTEX_WAIT, 4146, NULL <unfinished ...>
+++ killed by SIGSEGV +++