Deneteth
Deneteth

Reputation: 21

Catalyst / FCGI: myapp_fastcgi.pl won't work under Windows x64

I'm facing an issue with Calatylst while trying to use the myapp_fastcgi.pl script under windows x64 (Win 2008 R2 and Windows 7).

For some reasons when I try to access the script via an http server I get a "this application encountered an internal error" (I get this with both IIS7.5 and Apache 2.4). Trying to pin point the issue, I ran the script in a DOS console and I get this:

Use of uninitialized value $value in pattern match (m//) at D:/perl/site/lib/Config/General.pm line 872.
Use of uninitialized value in concatenation (.) or string at D:/perl/site/lib/Plack/Handler/FCGI.pm line 114, <DATA> line 998.
Use of uninitialized value in quotemeta at D:/perl/site/lib/Plack/Handler/FCGI.pm line 116, <DATA> line 998.
Use of uninitialized value in string eq at D:/perl/site/lib/Catalyst.pm line 2770, <DATA> line 998.
Use of uninitialized value $host in substitution (s///) at D:/perl/site/lib/Catalyst/Engine.pm line 444, <DATA> line 998.
Use of uninitialized value $host in concatenation (.) or string at D:/perl/site/lib/Catalyst/Engine.pm line 451, <DATA> line 998.
Use of uninitialized value $host in concatenation (.) or string at D:/perl/site/lib/Catalyst/Engine.pm line 459, <DATA> line 998.
Use of uninitialized value in string eq at D:/perl/site/lib/Catalyst/Action/RenderView.pm line 51, <DATA> line 998.
binmode() on unopened filehandle GEN2 at D:/perl/site/lib/Plack/Handler/FCGI.pm line 165, <DATA> line 998.
print() on unopened filehandle GEN2 at D:/perl/site/lib/Plack/Handler/FCGI.pm line 177, <DATA> line 998.
Use of uninitialized value in string eq at D:/perl/site/lib/Catalyst.pm line 1817, <DATA> line 998.
print() on unopened filehandle GEN2 at D:/perl/site/lib/Plack/Handler/FCGI.pm line 179, <DATA> line 998.

I don't mind the initialization errors much as in such conditions most of the environment set by an http server is missing. Yet the three errors on the "GEN2" filehandler intrigue me as I get the following output when I try the exact same script under an x32 environment (Windows XP):

<same init errors>
Use of uninitialized value in string eq at D:/Perl/site/lib/Catalyst/Action/RenderView.pm line 51, <DATA> line 998.
Status: 302 Found
Location: http:///login
Content-Length: 292
Content-Type: text/html; charset=utf-8
Set-Cookie: myapp_session=1e5994a41ea40c41764c4f2c0dc45592ef4b520f; path=/;
expires=Wed, 25-Apr-2012 17:14:25 GMT; HttpOnly
X-Catalyst: 5.90011

Use of uninitialized value in string eq at D:/Perl/site/lib/Catalyst.pm line 1817, <DATA> line 998.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x
html1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Moved</title>
  </head>
  <body>
     <p>This item has moved <a href="http:///login">here</a>.</p>
  </body>
</html>

which sounds more like what I should get on my x64 environment if it was working properly.

Looking a bit in the FCGI.pm module hints me that for some reasons *STDIN and *STDOUT are not open under x64 but I can't figure out why and I have no error about this. So I came here for any advice or idea or if anyone encountered this kind of issue before and solved it I'm eager to know the solution :)

A bit more about the tests I did:

Thanks in advance !

Upvotes: 1

Views: 623

Answers (1)

Deneteth
Deneteth

Reputation: 21

This will need further testing but after a modules comparison it apprears that the version of Plack::Handler::FCGI on the XP was older than the one that is available on the ppm repositories and that I was installing on the servers and the Windows 7.

Both versions have different ways to open stdin, stdout and stderr.

Older FCGI.pm version (no GEN2 error):

( .. some code ..)

my %env;
    my $request = FCGI::Request(
        \*STDIN, \*STDOUT,

        ($self->{keep_stderr} ? \*STDOUT : \*STDERR), \%env, $sock,
        ($self->{nointr} ? 0 : &FCGI::FAIL_ACCEPT_ON_INTR),
    );

New FCGI.pm version (GEN2 error):

( .. some code ..)

   @{$self}{qw(stdin stdout stderr)} 
      = (IO::Handle->new, IO::Handle->new, IO::Handle->new);

    my %env;
    my $request = FCGI::Request(

        $self->{stdin}, $self->{stdout},
        ($self->{keep_stderr} ? $self->{stdout} : $self->{stderr}), \%env, $sock,
        ($self->{nointr} ? 0 : &FCGI::FAIL_ACCEPT_ON_INTR),
    );

Subsequent interactions are done via $self->{stdxxx} instead of *STDxxx as before.

I'm not sure how it is intended to work in the lastest version but replacing the new Plack module FCGI.pm by the old one removes the GEN2 error on all systems. I'll ask the Plack guys for details...

Thanks again for the comments, it pointed me in the right direction.

Upvotes: 1

Related Questions