Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Plack CPAN distribution.

Report information
The Basics
Id: 57111
Status: rejected
Priority: 0/
Queue: Plack

People
Owner: Nobody in particular
Requestors: jnareb [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: "Use of uninitialized value in list assignment at CGI/Emulate/PSGI.pm line 21, <DATA> line 16", when using HTTP::Server::Simple::PSGI
I am running gitweb.cgi Perl CGI script from plackup (Plack version 0.9929) via attached wrapper, using Plack::App::WrapCGI, which in turn uses CGI::Emulate::PSGI (version 0.07). It works correctly when running this wrapper using "plackup --app gitweb.psgi", which in turn uses HTTP::Server::PSGI as web server. But when I tried to use HTTP::Server::Simple::PSGI server, via "plackup --server HTTP::Server::Simple --app gitweb.psgi", it generates the following runtime error (when connecting to web server using "lynx http://0:5000/"): Use of uninitialized value in list assignment at ~/perl5/lib/perl5/CGI/Emulate/PSGI.pm line 21, <DATA> line 16. This error is repeated three times for a single access. The page that is served using HTTP::Server::Simple::PSGI is generated incorrectly, and in my case it has 2152 bytes as compared to correctly generated page when using HTTP::Server::PSGI with 5729 bytes. Plack 0.9929 HTTP::Server::Simple::PSGI 0.14 HTTP::Server::Simple 0.42 CGI::Emulate::PSGI 0.07 CGI::Compile 0.11 perl, v5.8.6 built for i386-linux-thread-multi Linux kernel 2.6.14-11.1.aur.2 -- Jakub Narebski
Subject: gitweb.psgi
Download gitweb.psgi
text/x-perl 531b
#!/usr/bin/perl # gitweb - simple web interface to track changes in git repositories # PSGI wrapper (see http://plackperl.org) use strict; use warnings; use Plack::Builder; use Plack::App::WrapCGI; use CGI::Emulate::PSGI 0.07; # minimum version required to work use File::Spec; # __DIR__ is taken from Dir::Self __DIR__ fragment sub __DIR__ () { File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]); } builder { enable 'Debug'; Plack::App::WrapCGI->new(script => __DIR__."/gitweb.cgi")->to_app; }
Subject: "Use of uninitialized value in list assignment at CGI/Emulate/PSGI.pm line 21, <DATA> line 16", when using HTTP::Server::Simple::PSGI - simplified
From: Jakub Narebski <jnareb [...] gmail.com>
Download (untitled) / with headers
text/plain 1.5k
I have managed to simplify code that triggers this error. You would only need those two attached files: 'app.psgi' and 'test.cgi', which should be downloaded to the same directory. Using HTTP::Server::PSGI works correctly: $ plackup HTTP::Server::PSGI: Accepting connections at http://0:5000/ ## <-- here "lynx http://0:5000/" is run --> 127.0.0.1 - - [01/maj/2010 15:18:46] "GET / HTTP/1.0" 200 145 "-" "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7f" ^C Using HTTP::Server::Simple::PSGI I get this error: $ plackup -s HTTP::Server::Simple HTTP::Server::Simple::PSGI: Accepting connections at http://0:5000/ ## <-- here "lynx http://0:5000/" is run --> Use of uninitialized value in list assignment at /home/jnareb/perl5/lib/perl5/CGI/Emulate/PSGI.pm line 21, <DATA> line 16. Use of uninitialized value in list assignment at /home/jnareb/perl5/lib/perl5/CGI/Emulate/PSGI.pm line 21, <DATA> line 16. Use of uninitialized value in list assignment at /home/jnareb/perl5/lib/perl5/CGI/Emulate/PSGI.pm line 21, <DATA> line 16. 127.0.0.1 - - [01/maj/2010 15:21:28] "GET / HTTP/1.0" 200 145 "-" "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7f" ^C However this example does not show the second part of error, namely that the web page generated when server used by plackup is HTTP::Server::Simple::PSGI is not generated correctly. Plack 0.9933 HTTP::Server::Simple::PSGI 0.14 HTTP::Server::Simple 0.42 CGI::Emulate::PSGI 0.07 CGI::Compile 0.11 CGI 3.10 perl v5.8.6 -- Jakub Narebski
Subject: app.psgi
Download app.psgi
text/x-perl 295b
#!/usr/bin/perl use strict; use warnings; use Plack::App::WrapCGI; use File::Spec; # __DIR__ is taken from Dir::Self __DIR__ fragment sub __DIR__ () { File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]); } Plack::App::WrapCGI->new(script => __DIR__."/test.cgi")->to_app;
Subject: test.cgi
Download test.cgi
application/x-cgi 417b

Message body not shown because it is not plain text.

Subject: The warning is a red herring, and is not present in newer perls
From: Jakub Narebski <jnareb [...] gmail.com>
Download (untitled) / with headers
text/plain 2.2k
On Sob 01 Maj 2010, 09:28:53, http://jnareb.openid.pl/ wrote: Show quoted text
> I have managed to simplify code that triggers this error. You would > only need those two attached files: 'app.psgi' and 'test.cgi', which > should be downloaded to the same directory.
Show quoted text
> Using HTTP::Server::Simple::PSGI I get this error: > > $ plackup -s HTTP::Server::Simple > HTTP::Server::Simple::PSGI: Accepting connections at http://0:5000/ > ## <-- here "lynx http://0:5000/" is run --> > Use of uninitialized value in list assignment at > /home/jnareb/perl5/lib/perl5/CGI/Emulate/PSGI.pm line 21, <DATA> line 16.
Show quoted text
> However this example does not show the second part of error, namely that > the web page generated when server used by plackup is > HTTP::Server::Simple::PSGI is not generated correctly. > > > Plack 0.9933 > HTTP::Server::Simple::PSGI 0.14 > HTTP::Server::Simple 0.42 > CGI::Emulate::PSGI 0.07 > CGI::Compile 0.11 > CGI 3.10 > perl v5.8.6
This warning turned out to be red herring, unrelated to the issue of the wrong output from gitweb.cgi. miyagawa (Tatsuhiko Miyagawa) on #plack was not able to reproduce this warning with perl 5.10.1 and 5.8.9 (no warnings): <@miyagawa> do you have other perl? <@miyagawa> i tested with 5.10.1 and 5.8.9 <@miyagawa> no warnings This (incorrect) warning was caused by the fact that when using HTTP::Server::Simple::PSGI the %$env hash contains few entries ('CONTENT_LENGTH', 'CONTENT_TYPE' and 'HTTP_COOKIE') that have undefined *values*. The following change silences warnings: -- a/CGI/Emulate/PSGI.pm 2010-05-02 04:15:41.000000000 +0200 +++ b/CGI/Emulate/PSGI.pm 2010-05-02 11:25:26.000000000 +0200 @@ -48,7 +48,7 @@ REMOTE_HOST => 'localhost', REMOTE_PORT => int( rand(64000) + 1000 ), # not in RFC 3875 # REQUEST_URI => $uri->path_query, # not in RFC 3875 - ( map { $_ => $env->{$_} } grep !/^psgi\./, keys %$env ) + ( map { $_ => $env->{$_} } grep { defined $env->{$_} } grep !/^psgix?\./, keys %$env ) }; return wantarray ? %$environment : $environment; But: <@miyagawa> jnareb: i won't add grep { defined $env->{$_} } because that's a wrong fix <@miyagawa> deleting HTTP_COOKIE and CONTENT_LENGTH and CONTENT_TYPE from HTTP::Server::Simple::PSGI might be acceptable
Subject: The bug was "close $fd or return;" in gitweb code, while HTTP::Server::Simple sets $SIG{CHLD} to 'IGNORE'
From: Jakub Narebski <jnareb [...] gmail.com>
Download (untitled) / with headers
text/plain 1.2k
On Sob 01 Maj 2010, 06:29:58, http://jnareb.openid.pl/ wrote: Show quoted text
> I am running gitweb.cgi Perl CGI script from plackup (Plack version > 0.9929) via attached wrapper, using Plack::App::WrapCGI, which in turn > uses CGI::Emulate::PSGI (version 0.07). > > It works correctly when running this wrapper using "plackup --app > gitweb.psgi", which in turn uses HTTP::Server::PSGI as web server. > > But when I tried to use HTTP::Server::Simple::PSGI server, via "plackup > --server HTTP::Server::Simple --app gitweb.psgi" [...] The page > [...] is generated incorrectly, and > in my case it has 2152 bytes as compared to correctly generated page > when using HTTP::Server::PSGI with 5729 bytes. > > Plack 0.9929 > HTTP::Server::Simple::PSGI 0.14 > HTTP::Server::Simple 0.42 > perl, v5.8.6 built for i386-linux-thread-multi
The problem was that gitweb code contains the following construct: open my $fd, "-|", git_cmd(), 'for-each-ref' or return; my $most_recent = <$fd>; close $fd or return; But HTTP::Server::Simple sets $SIG{CHLD} to 'IGNORE', therefore "close $fd or return;" fails because of 'No child process'. "Closing any piped filehandle causes the parent process to wait for the child to finish"... and the child got reaped automatically because of $SIG{CHLD} = 'IGNORE'. This is not bug in Plack, then.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.