I'm coding in a mod_perl environment and using the Apache2::Request module to get posted data. This works fine, except for when I also use the Apache2::Request object also to upload a file/get the file's filehandle. If use the methods separately, there are no issues. However, if I use them both in the same subroutine, I get this error in my Apache log file:
[notice] child pid 27383 exit signal Segmentation fault (11)
Here is my code:
my $r = shift;
use Apache2::Request;
use Apache2::Upload;
my $req = Apache2::Request->new($r, POST_MAX => 10 * 1024 * 1024,DISABLE_UPLOADS => 0);
my $img_url = $req->param('url');
my $upload = $req->upload('files[]');
my $filename = $upload->filename;
my $upload_filehandle = $upload->fh;
my $file_size = $upload->size;
Apache2::Upload is included because it is used by Apache2::Request. Like I said, if I comment out either the line that begins with "my $img_url.." or the upload section, it works fine. However, if they are both present in the code, I get a 502 Proxy Error and that error in the apache log file.
Thanks in advance!
I appreciate this is an old question so my reply is a little late, but in case anyone else stumbles across this thread I do have a solution.
The problem is a mod_perl bug with New():
my $req = Apache2::Request->New($r);
(in your case, you have a few other things defined in there, but it looks to be the same segfaults and sporadic symptoms that I was suffering from).
Apache2::Request segfaults when $r isn't define, but sometimes it seems to segfault even when you've shifted @_ into $r (as you have done). I can't explain why this happens, but I have found a simple change that has stopped this issue from happening:
my $req = Apache2::Request->New(Apache2::RequestUtil->request);
So your code would presumably read as follows:
my $req = Apache2::Request->new(Apache2::RequestUtil->request,
POST_MAX => 10 * 1024 * 1024,
DISABLE_UPLOADS => 0);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.