http://www.perlmonks.org?node_id=1030793

prashantktyagi has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I am installing Net::Daemon (v0.48) from source. I am on activestate Perl v 5.16.3 (Win 7 64 bit). make test return failure and cause perl interpreter to stop working in t/threadm.t test. I debugged test and found this.
c:\Perl64\cpan\build\Net-Daemon-0.48-ISrOkZ>perl "-MExtUtils::Command: +:MM" "-e" "test_harness(1, 'blib\lib', 'blib\arch')" t/ithreadm.t t/ithreadm.t .. Starting server: C:\Perl64\bin\perl.exe -Iblib/lib -Iblib/arch t/serve +r --mode=ithreads logfile=stderr debug Starting process: proc = C:\Perl64\bin\perl.exe, args = C:\Perl64\bin\ +perl.exe -Iblib/lib -Iblib/arch t/server --mode=ithreads logfile=stde +r r debug 1..10 ok 1 Dubious, test returned 116 (wstat 29696, 0x7400) Failed 9/10 subtests Test Summary Report ------------------- t/ithreadm.t (Wstat: 29696 Tests: 1 Failed: 0) Non-zero exit status: 116 Parse errors: Bad plan. You planned 10 tests but ran 1. Files=1, Tests=1, 5 wallclock secs ( 0.06 usr + 0.00 sys = 0.06 CPU +) Result: FAIL Failed 1/1 test programs. 0/1 subtests failed.
I have checked the test code and it is failing on $tid->join(). That time I can see mutiple instance of perl process in the system.
my @threads; for (my $i = 0; $i < 10; $i++) { #print "Spawning child $i.\n"; my $tid = threads->new(\&MyChild, $i); if (!$tid) { print STDERR "Failed to create new thread: $!\n"; exit 1; } push(@threads, $tid); } eval { alarm 1; alarm 0 }; alarm 120 unless $@; for (my $i = 1; $i <= 10; $i++) { my $tid = shift @threads; #culprit==== if ($tid->join()) { print "ok $i\n"; } else { print "not ok $i\n"; } }
I have checked cpan-rt and found similiar bug https://rt.cpan.org/Public/Bug/Display.html?id=75005, but the workaround didn't solve my problem. When I modify condition
if (1) { print "ok $i\n"; } else {
test went pass. I am not much familiar with threads, so why this is causing the problem. Is this a test problem? should I report a bug on cpan RT ?
Thanks,
updated title ,typo in name.