perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arthur Bergman <>
Subject Problem with tied STDIN, mod_perl 1.26 and perl 5.6.1
Date Tue, 14 May 2002 09:51:57 GMT

After tons of debugging a case when I lost CGI POST variables I 
discovered the following.

In perl 5.6.1, certain operations can cause references to filehandles to 
loose TIE magic even when the filehandle is tied.


use strict;
use IO::Scalar;
sub IO::Scalar::FILENO {};
my $scalar = "";
tie *STDIN, 'IO::Scalar', \$scalar;
my $fh = \*STDIN;
print $fh "HI";
print "---$scalar---\n";

Removing the fileno(STDIN), makes the above example work. This is fixed 
in perl 5.8 to be, I don't know how far back it has effect I only tried 
it under 5.6.1.

The result is that if a module does fileno(STDIN), or any of the other 
potential ops (Anyone doing sv_setsv on a glob), any references to STDIN 
will not be tied, however since reads STDIN for post data from a 
reference to STDIN, and mod_perl makes it tied, suddenly post data will 
not appear.
Worst case it will hang since it does a read( from /dev/null which is 
what plain STDIN is under apache on linux).

The following patch corrects the problem without having any bad side 
effects as far as I know.

---     Wed Apr 10 21:36:01 2002
+++      Tue May 14 11:34:22 2002
@@ -450,7 +450,7 @@

        if ($meth eq 'POST') {
               if $content_length > 0;
           # Some people want to have their cake and eat it too!
           # Uncomment this line to have the contents of the query string


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message