Perl崩溃:在线程中错误地使用了glob?

时间:2014-05-13 11:11:44

标签: multithreading perl glob

以下脚本在perl 5.16中崩溃。在线程中使用glob()有什么问题吗?

use strict;
use warnings;
use 5.010;

use threads; 

sub f { 
    my $no = shift; 
    my @arr = glob("*"); 
    say "thread $no: ", scalar(@arr); 
} 

foreach my $tno (1..5) { 
    my $thr = threads->create(\&f, $tno); 
    $thr->join(); 
}

打印

thread 1: 33

然后崩溃并出现分段错误(MacOS)或访问冲突(Windows 7)。 使用v5.16.2 on Mac OSX (darwin-thread-multi-2level)ActivePerl on Windows 7 64bit (v5.16.3 built for MSWin32-x86-multi-thread)进行了测试。

1 个答案:

答案 0 :(得分:6)

这是bug in perl,我fixed 5.18.2 {{3}}。{/ p>