Subject: | [FCGI.pm] - not threads-safe? |
Date: | Sun, 18 Aug 2013 18:36:25 +0300 |
To: | bug-fcgi [...] rt.cpan.org |
From: | zdm <zdm [...] softvisio.net> |
Hello.
Following code produce segmentation fault:
----------------------------------------------------------------
#!/usr/bin/env perl
use v5.16.3;
use threads (exit => 'threads_only');
use threads::shared;
use FCGI;
threads->create(\&thread);
threads->create(\&thread);
threads->create(\&thread);
while (threads->list(threads::all)) { sleep 1 } #wait until has threads
sub thread {
sleep 3;
threads->detach;
threads->exit;
return;
}
1;
__END__
----------------------------------------------------------------
but if if require FCGI first time in thread, such as:
----------------------------------------------------------------
#!/usr/bin/env perl
use v5.16.3;
use threads (exit => 'threads_only');
use threads::shared;
threads->create(\&thread);
threads->create(\&thread);
threads->create(\&thread);
while (threads->list(threads::all)) { sleep 1 } #wait until has threads
sub thread {
require FCGI; # <--- HERE IS THE DIFFERENCE
sleep 3;
threads->detach;
threads->exit;
return;
}
1;
__END__
----------------------------------------------------------------
thread can exit without any errors.
This bug prevent use FCGI.pm with threads.