我有一個使用coro版本6.06的Perl代碼。perl coro分段錯誤
這是我的代碼:
{
package AAA;
use AnyEvent::HTTP::LWP::UserAgent;
use Coro;
use Coro::AnyEvent; BEGIN { *CORE::GLOBAL::sleep = \&Coro::AnyEvent::sleep; };
sub new { return bless {} => shift };
sub main {
my ($self) = @_;
my $count = 1000;
my $h = {};
while (1) {
while (keys %$h >= $count) {
sleep 1;
}
my $task = rand(1000);
my $coro = async (
sub {
my ($self, $task) = @_;
sleep(rand(1000));
print ": $self - $coro - $task\n";
} => ($self, $task)
);
$h->{$coro} = $coro;
$coro->on_destroy(sub {
delete $h->{$coro};
undef $coro;
});
}
}
}
AAA->new->main;
不時(如1次在一天),它失敗分段錯誤。
它可能是什麼錯誤,我如何檢測它?
Coro版本是6.06 – Nikita