I tried to install AnyEvent::ForkManager on Cygwin. Both its main dependencies, AnyEvent and Parallel::ForkManager, installed without problems, but the module itself hung right after the first test in 001_basic.t:
~/.cpan/build/AnyEvent-ForkManager-0.04-ZOUXbL$ ./Build test t/000_load.t ...... 1/1 # Testing AnyEvent::ForkManager/0.04 t/000_load.t ...... ok t/001_basic.t ..... 1/63
I sprinkled the code with tracing warns to discover where exactly the code gets stuck. The following line never finished:
$pm->start( cb => sub { my($pm, $exit_code) = @_; local $SIG{USR1} = sub { $started_all_process = 1; }; isnt $$, $pm->manager_pid, 'called by child'; # <<== + HERE until ($started_all_process) {}; # wait note "exit_code: $exit_code"; $pm->finish($exit_code); fail 'finish failed'; }, args => [$exit_code] );
At first, I though that's manager_pid that doesn't return, but after replacing the line with
my $mpid = $pm->manager_pid; isnt $$, $mpid, 'called by child';
it became obvious it's the isnt line that causes the issue. I delved more deeply and found out it comes from Test::SharedFork. It uses flock to lock a file that shares the information between forks. The Store::Locker is constructed with the following:
sub new { my ($class, $store) = @_; $store->_reopen_if_needed; if ($store->{lock}++ == 0) { flock $store->{fh}, LOCK_EX or die $!; # <<== HERE } bless { store => $store }, $class; }
The code stops on the flock line and stays there forever (on Linux, it works correctly). I wanted to know more, so I prepended the following to the line:
use Data::Dumper; $Data::Dumper::Deparse = 1; warn Dumper($store);
Not only was I able to see the structure, but all the tests passed. "A race condition," though I and replaced the line with
use Time::HiRes qw{ usleep }; usleep 200;
Result: PASS. When lowering the value, the tests sometimes hung again.
Thanks. The issue lives outside of PM at github, too.
In reply to AnyEvent::ForkManager fails tests on Cygwin by choroba
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |