This happens running under mod_perl2 using Apache2::Request to process a submitted form that has <input type="file" ...> when the user does not specify a file. It looks like execution of the perl code abruptly ends at the call to ->upload(). No error is written to the error log, but the browser gets a response with content up until that call.
I have built a minimal handler to demonstrate this. You can try it at
http://backdev.nber.org/uploadtest
To see the bug, select a file for the first field but not the second.
This is called with the following simple Apache config:
PerlModule NBER::UploadDebug::UploadTest <Location "/uploadtest"> SetHandler perl-script PerlResponseHandler NBER::UploadDebug::UploadTest </Location>
package NBER::UploadDebug::UploadTest; use Apache2::Request; use Apache2::RequestUtil; use Apache2::Upload; sub handler { my $r = shift; $r->content_type("text/html; charset=utf-8"); if ($r->method eq 'POST') { print "<html><body><h1>Form submitted</h1><pre>\n"; print "About to get Apache2::Request->new\n"; $req = Apache2::Request->new($r, TEMP_DIR => '/tmp'); my @params = $req->param(); print "all params: " . join(",",@params) . "\n"; my @filefieldnames = ('file1','file2'); print "filefieldnames:" . join(",",@filefieldnames) . "\n"; foreach my $n (@filefieldnames) { print "About to check param $n\n"; next unless $req->param($n); print "About to call upload on $n\n"; my $fref = $req->upload($n); print "filename for $n: " . $fref->filename() ."\n"; } print "after names loop\n"; } else { print qq[ <html> <body> <h1>This is the form</h1> <br> <form name="theform" method="POST" enctype="multipart/form-data"> file1: <input type="file" name="file1"> <br> file2: <input type="file" name="file2"> <br> <input type="submit" value="submit"> </form> </body> </html> ]; } return Apache2::Const::OK; } sub new { my $proto = shift; my $class = ref($proto) || $proto; bless $self, $class; } 1;
The bug is not triggered on our production web server, which is running:
FreeBSD bsdtest 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64 apache24-2.4.53_1 apr-1.7.3.1.6.3_1 libapreq2-2.13_5 p5-libapreq2-2.16 ap24-mod_perl2-2.0.12,3
The bug is triggered on a fairly recent FreeBSD with up to date packages, but also on
FreeBSD bsdtestbug 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64 apache24-2.4.58_1 apr-1.7.3.1.6.3_1 libapreq2-2.17 p5-libapreq2-2.16 ap24-mod_perl2-2.0.12,3