-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:
After doing a subrequest, the ENV hash is being cleared of everything except MOD_PERL and MOD_PERL_API_VERSION. The ENV is normal within the subrequest and immediately after, but ENV is lost after leaving the code block (or subroutine) that contains the subrequest call. This script illustrates the problem:
#!perl -w
use strict;
use Apache2::RequestUtil;
use Apache2::TrapSubRequest; #Used here, but problem occurs with standard $subr->run also.
# See what happens in this block
{
#local %ENV; #This preserves ENV, but causes loss of MOD_PERL and MOD_PERL_API_VERSION
my $r = Apache2::RequestUtil->request();
my $subr = $r->lookup_uri('/insideph/phin_news_portlet');
# uses Apache2::TrapSubRequest
my $data;
$subr->run_trapped(\$data);
&check_env('1'); #ENV is ok here
}
&check_env('2'); #ENV contains ONLY MOD_PERL and MOD_PERL_API_VERSION here
sub check_env {
my $id = shift;
for (keys(%ENV)) {
warn "$id -- $_: ". $ENV{$_} ."\n";
}
warn "-------------------------------------------\n";
}
2. Used Components and their Configuration:
*** mod_perl version 2.000002
*** using /opt/perl-5.8/lib/site_perl/5.8.7/i686-linux-thread-multi/Apache2/BuildConfig.pm
*** Makefile.PL options:
MP_APR_LIB => aprext
MP_APXS => /opt/apache2/bin/apxs
MP_COMPAT_1X => 1
MP_GENERATE_XS => 1
MP_LIBNAME => mod_perl
MP_USE_DSO => 1
*** The httpd binary was not found
Here it is:
/opt/apache2/bin/httpd -V
Server version: Apache/2.0.55
Server built: Nov 6 2005 17:15:01
Server's Module Magic Number: 20020903:11
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/opt/apache2"
-D SUEXEC_BIN="/opt/apache2/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
*** /usr/bin/ldd /opt/apache2/bin/httpd
libz.so.1 => /usr/lib/libz.so.1 (0x00c7f000)
libssl.so.4 => /lib/libssl.so.4 (0x00468000)
libcrypto.so.4 => /lib/libcrypto.so.4 (0x00311000)
libaprutil-0.so.0 => /opt/apache2/lib/libaprutil-0.so.0 (0x00111000)
libdb-4.1.so => /lib/libdb-
4.1.so (0x00124000)
libexpat.so.0 => /opt/apache2/lib/libexpat.so.0 (0x00bd8000)
libapr-0.so.0 => /opt/apache2/lib/libapr-0.so.0 (0x00c9c000)
librt.so.1 => /lib/tls/librt.so.1 (0x0049e000)
libm.so.6 => /lib/tls/libm.so.6 (0x00b30000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x004d2000)
libnsl.so.1 => /lib/libnsl.so.1 (0x004ba000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00c36000)
libdl.so.2 => /lib/libdl.so.2 (0x00b2a000)
libc.so.6 => /lib/tls/libc.so.6 (0x009fe000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x002fb000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00401000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x002d3000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x002d8000)
libresolv.so.2 => /lib/libresolv.so.2 (0x001de000)
/lib/ld-
linux.so.2 (0x009e5000)
*** (apr|apu)-config linking info
-L/opt/apache2/lib -laprutil-0 -ldb-4.1 -lexpat
-L/opt/apache2/lib -lapr-0 -lrt -lm -lcrypt -lnsl -lpthread -ldl
*** /opt/perl-
5.8/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
Platform:
osname=linux, osvers=2.4.21-32.0.1.elsmp, archname=i686-linux-thread-multi
uname='linux molly 2.4.21-32.0.1.elsmp
#1 smp tue may 17 17:52:23 edt 2005 i686 i686 i386 gnulinux '
config_args='-der'
hint=previous, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -g -fPIC -I/opt/perl-
5.8/local/include -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-g -O2 ',
cppflags='-D_REENTRANT -D_GNU_SOURCE -g -fPIC -I/opt/perl-5.8/local/include -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_REENTRANT -D_GNU_SOURCE -g -fPIC -I/opt/perl-
5.8/local/include -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
ccversion='', gccversion='3.2.3 20030502 (Red Hat Linux 3.2.3-52)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/perl-
5.8/lib/5.8.7/i686-linux-thread-multi/CORE'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS
USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Built under linux
Compiled at Sep 12 2005 12:52:00
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
/opt/perl-5.8/lib/5.8.7/i686-linux-thread-multi
/opt/perl-5.8/lib/5.8.7
/opt/perl-5.8/lib/site_perl/5.8.7/i686-linux-thread-multi
/opt/perl-5.8/lib/site_perl/5.8.7
/opt/perl-5.8/lib/site_perl
.
*** Packages of interest status:
Apache2 : -
Apache2::Request : 2.07
CGI : 3.10
ExtUtils::MakeMaker: 6.17
LWP : 5.803
mod_perl : -
mod_perl2 : 2.000002
3. This is the core dump trace: (if you get a core dump):
[CORE TRACE COMES HERE]
This report was generated by /opt/perl-5.8/bin/mp2bug on Wed Jun 21 19:45:41 2006 GMT.
-------------8<---------- End Bug Report --------------8<----------
- [mp2] %ENV lost after doing subrequest Ed Eddington
- Re: [mp2] %ENV lost after doing subrequest Philip M. Gollucci