Re: WELCOME to modperl@perl.apache.org

Re: WELCOME to modperl@perl.apache.org

am 12.02.2009 16:33:08 von earonesty

-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:

It's well known that file-scoped lexicals don't work intuitively in
CGI programs under mod_perl.

When mod_perl calls the same CGI program twice, file-scoped lexicals
are not rebound.

Some people are aware of this, random posts to newsgroups will attest,
but this is not documented well enough.

Create a CGI as below, and run it many times, assigning different
CGI::param('foo') values to $x.
Lowering the number of children spawned in Apache will reduce the
number of times needed
to run the script in order to see the problem.

# this program sometimes prints old values for foo, but only under mod_perl!

use CGI;
my $x =CGI::param('foo');

&y;

sub y {
print "content-type:text/plain\n\n?$x\n";
}

People using mod_perl expect CGI programs to behave similarly to how
they did before mod_perl.

mod_perl should be *extremely* verbose in pointing this change out to
developers, as
it is *extremely* difficult to diagnose.

Alternatively, it should be fixed. But I'm not sure how, since most
solutions involve creating
anonymous package scopes which require the recompiling and ruining of
mod_perl's speed
benefits.

Maybe there should just be a big fat warning on the top of the CGI
module and at the top of mod_perl,
"Don't use file-scoped lexicals!" Or something like that.

2. Used Components and their Configuration:

*** mod_perl version 2.000003

*** using /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/Apa che2/BuildConfig.pm

*** Makefile.PL options:
MP_APR_CONFIG => /usr/bin/apr-1-config
MP_APR_LIB => aprext
MP_APXS => /usr/sbin/apxs
MP_COMPAT_1X => 1
MP_GENERATE_XS => 1
MP_LIBNAME => mod_perl
MP_USE_DSO => 1


*** The httpd binary was not found


*** (apr|apu)-config linking info

-laprutil-1 -lldap -llber -ldb-4.5 -lexpat
-lapr-1 -lpthread -ldl



*** /usr/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.6.18-53.1.14.el5xen, archname=i386-linux-thread-multi
uname='linux xenbuilder4.fedora.phx.redhat.com
2.6.18-53.1.14.el5xen #1 smp tue feb 19 07:33:17 est 2008 i686 i686
i386 gnulinux '
config_args='-des -Doptimize=-O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
-fasynchronous-unwind-tables -Dversion=5.8.8 -Dmyhostname=localhost
-Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc.
-Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux
-Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads
-Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db
-Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio
-Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly
-Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto
-Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto
-Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto
-Dinc_version_list=5.8.7 5.8.6 5.8.5 -Dscriptdir=/usr/bin'
hint=recommended, 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='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE
-fno-strict-aliasing -pipe -Wdeclaration-after-statement
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/include/gdbm',
optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
-mtune=generic -fasynchronous-unwind-tables',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-Wdeclaration-after-statement -I/usr/local/include
-I/usr/include/gdbm'
ccversion='', gccversion='4.1.2 20070925 (Red Hat 4.1.2-27)',
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='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.6.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.6'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE '
cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
-fasynchronous-unwind-tables -L/usr/local/lib'

Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at May 5 2008 10:33:58
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl/5.8.7
/usr/lib/perl5/site_perl/5.8.6
/usr/lib/perl5/site_perl/5.8.5
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8
/usr/lib/perl5/vendor_perl/5.8.7
/usr/lib/perl5/vendor_perl/5.8.6
/usr/lib/perl5/vendor_perl/5.8.5
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/5.8.8
.

*** Packages of interest status:

Apache2 : -
Apache2::Request : -
CGI : 3.15
ExtUtils::MakeMaker: 6.30
LWP : 5.805
mod_perl : -
mod_perl2 : 2.000003


3. This is the core dump trace: (if you get a core dump):

[CORE TRACE COMES HERE]

This report was generated by /usr/bin/mp2bug on Thu Feb 12 15:14:33 2009 GMT.

-------------8<---------- End Bug Report --------------8<----------

Note: Complete the rest of the details and post this bug report to
modperl perl.apache.org. To subscribe to the list send an empty
email to modperl-subscribe@perl.apache.org.

Re: WELCOME to modperl@perl.apache.org

am 12.02.2009 17:11:33 von mpeters

Erik Aronesty wrote:

> mod_perl should be *extremely* verbose in pointing this change out to
> developers, as
> it is *extremely* difficult to diagnose.

Maybe ModPerl::Registry should do this, but not mod_perl itself. If someone is trying to get an old
CGI script to work under mod_perl then they'd use Registry. But there's no reason to make the rest
of us suffer for their old scripts.

> Alternatively, it should be fixed. But I'm not sure how, since most
> solutions involve creating
> anonymous package scopes which require the recompiling and ruining of
> mod_perl's speed
> benefits.

No, changing your code's structure or scope is not something that should be done automatically.

> Maybe there should just be a big fat warning on the top of the CGI
> module and at the top of mod_perl,
> "Don't use file-scoped lexicals!" Or something like that.

The problem with that is that they are useful for having things like Singleton's that don't change
between invocations of the script (like a Conf object).

--
Michael Peters
Plus Three, LP

Re: WELCOME to modperl@perl.apache.org

am 12.02.2009 17:26:12 von aw

Michael Peters wrote:
> Erik Aronesty wrote:
>
This can not be called "verbose", because it's rather hard to find, but
it's worth reading.

http://perl.apache.org/docs/general/perl_reference/perl_refe rence.html#toc_Remedies_for_Inner_Subroutines

But normally perl/mod_perl will warn you in the logfile, whenever you do
something of the kind, with a

Variable "$x" will not stay shared at ./nested.pl line 10