A thread exited while 2 threads were running. #### A thread exited while 2 threads were running. panic: MUTEX_LOCK (22) [op.c:352] during global destruction. #### my $thread = async { my $tid = threads->tid(); my ( $out, $in ); chdir $wd or die "Can't cd to $wd: $!\n"; my $pid = open2( $out, $in, $cmd ); # die "$!\n"; print $in "$_\n" foreach (@input); close $in or warn "close of input: $! $?\n"; my $err = 0; while (<$out>) { chomp; $err = 1 if (/^thread failed/); $Q->enqueue("$tid:$uut:$test:$_"); last if ($err); } kill( 2, $pid ) if $err; close $out; $Q->enqueue("$tid:$uut:$test:ENDEND"); waitpid ($pid, 0); }; $thread->detach(); #### my $tcount = count of tests that are running. while (1) { if ( $Q->pending ) { $_ = $Q->dequeue; chomp; if (/ENDEND$/) { $done++; print "\t-->got $done/$t_count $_\n"; } last if ( $done == $t_count ); next if (/ENDEND$/); } }