You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Beau E. Cox" <be...@beaucox.com> on 2004/01/29 12:12:18 UTC
[mp2] Apache Request and libapreq2 Cookie woes
-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:
I am porting a mod_perl 1.x system ( Mason ) to 2.0. This
is a totally unofficial effort, more for me to learn
mod_perl2 and Mason than anything else. The system
has in-place a scheme to pass the request object from
module to module ( method $self->apache_req ).
Becauuse of problems, I made the apache request global
( PerlOptions +GlobalRequest ) and used the Apache->request
global request accessor - it works fine that way.
Now I am trying to go back to the passed request object.
Here is what happens:
$self->apache_req->server->log->notice ( "try apache_req" );
-- logs OK
Apache->request->server->log->notice ( "try Apache->request" );
-- logs OK
($self->{cookie_class} is 'Apache::Cookie')
my $cookie =
$self->{cookie_class}->new( Apache->request, ... );
-- OK
my $cookie =
$self->{cookie_class}->new( $self->apache_req, ... );
-- Segmentation fault (11)
my $apr = Apache::Request->new( $self->apache_req );
-- Segmentation fault (11)
Apache->request->server->log->notice
( "global \$r => ", Apache->request );
-- prints:
[Thu Jan 29 00:29:28 2004] [notice] global $r =>
Apache::RequestRec=SCALAR(0x94cb658)
Apache->request->server->log->notice
( "\$self->apache_req => ", $self->apache_req );
--prints:
[Thu Jan 29 00:29:28 2004] [notice] $self->apache_req =>
Apache::Request=SCALAR(0x8ac6c9c)
The module's uses:
use Apache2;
use Apache::Session;
use Apache::RequestRec;
use Apache::RequestUtil;
use Apache::Cookie;
use CGI::Cookie;
use HTML::Mason 1.16;
use HTML::Mason::Exceptions ( abbr => [ qw( param_error error ) ] );
use HTML::Mason::Request;
I am befuttled(?sp?) that the $r->apache_req is able to log via
the ->server->log interface, but refuses to cookieize.
2. Used Components and their Configuration:
*** mod_perl version 1.9913
(NOTICE THAT I REMOVED THE DEFAULT COMPAT)
*** using lib/Apache/BuildConfig.pm
*** Makefile.PL options:
MP_APXS => /usr/apache2/sbin/apxs
MP_COMPAT_1X =>
MP_GENERATE_XS => 1
MP_LIBNAME => mod_perl
MP_USE_DSO => 1
MP_USE_STATIC => 1
*** /usr/apache2/sbin/httpd -V
Server version: Apache/2.0.48
Server built: Jan 26 2004 06:20:30
Server's Module Magic Number: 20020903:4
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/worker"
-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="/usr/apache2"
-D SUEXEC_BIN="/usr/apache2/bin/suexec"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/httpd/mime.types"
-D SERVER_CONFIG_FILE="/etc/httpd/httpd.conf"
*** /usr/bin/perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=linux, osvers=2.4.24-pre1.lm, archname=i686-linux-thread-multi
uname='linux cathy.beaucox.com 2.4.24-pre1.lm #1 thu dec 11 02:58:17 hst
2003 i686 unknown unknown gnulinux '
config_args='-Dprefix=/usr -d -e -Dusethreads'
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='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O3',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='3.3.2', 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
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=false, libperl=libperl.a
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Built under linux
Compiled at Dec 20 2003 03:01:43
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
/usr/lib/perl5/5.8.2/i686-linux-thread-multi
/usr/lib/perl5/5.8.2
/usr/lib/perl5/site_perl/5.8.2/i686-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1/i686-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1
/usr/lib/perl5/site_perl
.
*** Packages of interest status:
Apache::Request: 2.02-dev
CGI : 3.04
LWP : 5.69
mod_perl : 1.9913
3. This is the core dump trace: (if you get a core dump):
[CORE TRACE COMES HERE]
This report was generated by t/REPORT on Thu Jan 29 10:32:23 2004 GMT.
-------------8<---------- End Bug Report --------------8<----------
Note: Complete the rest of the details and post this bug report to
dev <at> perl.apache.org. To subscribe to the list send an empty
email to dev-subscribe@perl.apache.org.
Aloha => Beau;
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Apache Request and libapreq2 Cookie woes
Posted by Stas Bekman <st...@stason.org>.
Beau E. Cox wrote:
[...]
> The module's uses:
>
> use Apache2;
> use Apache::Session;
> use Apache::RequestRec;
> use Apache::RequestUtil;
> use Apache::Cookie;
> use CGI::Cookie;
BTW, you should not put 'use Apache2' in your modules (especially CPAN ones).
They mess up with @INC and some module/app that tries to load this module will
suddenly "discover" and use mod_perl 2 instead of mod_perl 1. Users using
mod_perl 2.0 already load this module at the server startup, they can't go
without it. So no need to load it in your code.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Apache Request and libapreq2 Cookie woes
Posted by Stas Bekman <st...@stason.org>.
> One followup question, is this call OK in mod_perl2?
>
> $r->headers_in->unset('Content-length');
>
> I have been changing all '$r->xxx_header_xxx' method
> calls in my porting, but this one stumps me.
what seems to be the problem, Beau? It should work just fine.
http://perl.apache.org/docs/2.0/api/APR/Table.html#C_unset_
p.s. please start a new thread when you change the thread's topic, thanks.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Apache Request and libapreq2 Cookie woes
Posted by "Beau E. Cox" <be...@beaucox.com>.
Cool - OK!
Please see below (one more question... :)
On Thursday 29 January 2004 06:29 am, Joe Schaefer wrote:
> "Beau E. Cox" <be...@beaucox.com> writes:
>
> [...]
>
> > ($self->{cookie_class} is 'Apache::Cookie')
> > my $cookie =
> > $self->{cookie_class}->new( Apache->request, ... );
> > -- OK
>
> This is correct usage, because Apache->request is an
> Apache::RequestRec object in mp2.
>
> > my $cookie =
> > $self->{cookie_class}->new( $self->apache_req, ... );
> > -- Segmentation fault (11)
> >
> > my $apr = Apache::Request->new( $self->apache_req );
> > -- Segmentation fault (11)
>
> These are (currently) incorrect calls, because the argument
> to new() MUST be an Apache::RequestRec object, not an
> Apache::Request object. The segfault is of course a bug
> in Apache::Request, but in the meantime you can avoid it by
> using env() to pull the base Apache::RequestRec object out of
> your Apache::Request object:
>
> my $cookie = $self->{cookie_class}->new($self->apache_req->env,...);
> my $apr = $self->apache_req; # (no need to call new() here)
>
> --
> Joe Schaefer
Thank you very much, Joe - works fine.
One followup question, is this call OK in mod_perl2?
$r->headers_in->unset('Content-length');
I have been changing all '$r->xxx_header_xxx' method
calls in my porting, but this one stumps me.
Aloha = Beau;
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Apache Request and libapreq2 Cookie woes
Posted by Joe Schaefer <jo...@sunstarsys.com>.
"Beau E. Cox" <be...@beaucox.com> writes:
[...]
> ($self->{cookie_class} is 'Apache::Cookie')
> my $cookie =
> $self->{cookie_class}->new( Apache->request, ... );
> -- OK
This is correct usage, because Apache->request is an
Apache::RequestRec object in mp2.
>
> my $cookie =
> $self->{cookie_class}->new( $self->apache_req, ... );
> -- Segmentation fault (11)
>
> my $apr = Apache::Request->new( $self->apache_req );
> -- Segmentation fault (11)
These are (currently) incorrect calls, because the argument
to new() MUST be an Apache::RequestRec object, not an
Apache::Request object. The segfault is of course a bug
in Apache::Request, but in the meantime you can avoid it by
using env() to pull the base Apache::RequestRec object out of
your Apache::Request object:
my $cookie = $self->{cookie_class}->new($self->apache_req->env,...);
my $apr = $self->apache_req; # (no need to call new() here)
--
Joe Schaefer
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html