Re: perl FCGI segmentation fault using ithreads ...
Sam Vilain <sam-s9IUA/[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
Igor,
You are doing this:
Master perl
-> load FCGI
-> create FCGI handle
-> accept FCGI socket
-> create new interpreter thread
->request
->request
If threading is giving you segfaults, it is a fairly safe bet that the
FCGI.pm module is not re-entrant.
Observe that you could move the thread creation to any point in the tree, eg
Master perl
-> load FCGI
-> create new interpreter thread
-> create FCGI handle
-> accept FCGI socket
->request
->request
-> create FCGI handle
-> accept FCGI socket
->request
->request
Depending on where the non-reentrancy bug in the FCGI.pm XS part lies,
you might be restricted to doing it before you even load the FCGI module.
If you can have a monitor thread that spots when all of the worker
threads are busy, you could keep a nice little managed threadpool, too.
Just a thought,
Sam.
Igor Suarez-Sola wrote:
> Hi,
>
> I imagine this is not new, so apologies in advance if this has been
> disscussed already but I haven't found an answer yet.
>
> I'd like to use FCGI and perl ithreads in the same application.
> However it looks like after one loop the application crashes with a
> segmentation fault.
>
> This is a example that reproduce the problem.
>
> use CGI::Fast qw(:standard *table *script *div start_ul -nosticky);
>
>
> use threads;
>
>
> my $count = 0;
> my $request = FCGI::Request();
>
>
> while(new CGI::Fast()) {
> {
> print("Content-type: text/html\r\n\r\n", ++$count,"\n");
> my @thArr =();
> for my $num (1..3)
> {
> my $thr = threads->create (\&dispatcher, $num);
> push @thArr, $thr;
> }
>
>
> for my $th (@thArr)
> {
> my $r = $th->join;
> if (defined($r)) {
> print "Thread id [",$r->{tid},"] ;; Order num [",$r->{num},"]
> ;; time [",$r->{time},"]\n";
> }
> }
> }
>
>
> sub dispatcher {
> my $num = shift;
> # does nothing only returns a hash;
> my $hash={};
> $hash->{time}=gmtime;
> $hash->{tid}=threads->self->tid;
> $hash->{num}=$num;
> return $hash;
> }
>
>
> 1;
> #########################
> If I call this cgi from apache I get in the logs:
> [Thu Aug 05 14:27:07 2004] [warn] FastCGI: server
> "/var/www/cgi-bin/VSO_FAST/votest.pl" (pid 14843) terminated due to
> uncaught signal '11' (Segmentation fault)
>
> If I run it manually I get a long list of errors like:
> Attempt to free non-existent shared string 'SSH_ASKPASS', Perl
> interpreter: 0x8350438 during global destruction.
>
>
> I'm using perl 5.8.5 , Apache/2.0.48 and mod_fastcgi 2.4.2
>
> Any info is most welcome!
>
> Thanks!
>
> Igor
>
> ___________________________________
> fastcgi-developers mailing list
> http://fastcgi.com/fastcgi-developers/
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/