Skip Menu |

This queue is for tickets about the Apache-Session-Wrapper CPAN distribution.

Report information
The Basics
Id: 20992
Status: resolved
Worked: 3 hours (180 min)
Priority: 0/
Queue: Apache-Session-Wrapper

People
Owner: Nobody in particular
Requestors: derek [...] ximbiot.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.31
Fixed in: 0.32



Subject: _bake_cookie sets empty (undef?) value when deleting sessions
When $w->delete_session is called, the program aborts with an error like "attempt to call method of undefined value" at line 738. This is because Apache2::Cookie->new is returning `undef' when it is passed an undefined value for the "value" parameter. I hacked around this by deleting the cookie before deleting the session id in delete_session(). Patch attached.
Subject: session-wrapper.diff
--- /usr/local/share/perl/5.8.7/Apache/Session/Wrapper.pm 2006-08-09 14:27:36.000000000 -0400 +++ apache2/XimbiotSessionWrapper.pm 2006-08-14 19:08:41.000000000 -0400 @@ -790,9 +790,9 @@ (tied %$session)->delete; - delete $self->{session_id}; - $self->_bake_cookie('-1d') if $self->{use_cookie}; + + delete $self->{session_id}; } sub cleanup_session
On Mon Aug 14 19:12:42 2006, DPRICE wrote: Show quoted text
> When $w->delete_session is called, the program aborts with an error like > "attempt to call method of undefined value" at line 738. > > This is because Apache2::Cookie->new is returning `undef' when it is > passed an undefined value for the "value" parameter.
Is this a bug in Apache2::Cookie? It seems like it, since it's a change in behavior compared to Apache::Cookie, and it's not documented anywhere. Could you report this to the libapreq2 maintainer?
From: derek [...] ximbiot.com
It might be a bug in Apache2::Cookie or an undocumented API change, but when the work-around is so simple, why not implement it in Apache::Session::Wrapper? Some distros take so long to update their mod_perl package, and some production systems avoid upgrades to such a degree, that it might be years before Apache2::Session::Wrapper begins working again on those platforms if it waits for the libapreq2 fix to trickle down. Thanks,
Subject: Re: [rt.cpan.org #20992] _bake_cookie sets empty (undef?) value when deleting sessions
Date: Mon, 18 Sep 2006 09:49:40 -0500 (CDT)
To: "Derek R. Price via RT" <bug-Apache-Session-Wrapper [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Mon, 18 Sep 2006, Derek R. Price via RT wrote: Show quoted text
> It might be a bug in Apache2::Cookie or an undocumented API change, but > when the work-around is so simple, why not implement it in > Apache::Session::Wrapper? Some distros take so long to update their > mod_perl package, and some production systems avoid upgrades to such a > degree, that it might be years before Apache2::Session::Wrapper begins > working again on those platforms if it waits for the libapreq2 fix to > trickle down.
Because I'd rather require a working Apache2::Cookie than have lots of hacks based on package and version # in the code. If I support a workaround for this bug I have to keep doing that, and it's one more thing to worry about. If it _is_ a bug in libapreq2, it should be fixed, right? Meanwhile, it's easy enough to workaround by just using CGI::Cookie.
On Mon Sep 18 11:17:09 2006, autarch@urth.org wrote: Show quoted text
> Because I'd rather require a working Apache2::Cookie than have lots of > hacks based on package and version # in the code.
Since, as you point out, the behavior of Apache2::Cookie->new with an undefined value for -version is undocumented, whether this is a bug or you were depending on undefined behavior may still be up for debate. Do you care to have that our with the libapreq2 folks? Show quoted text
> If I support a workaround for this bug I have to keep doing that, and
it's Show quoted text
> one more thing to worry about.
Since the workaround should be backward compatible, I don't see what you would have to "keep doing". Why would expiring the cookie before deleting the session ID from the hash break when run against any other libapreq version? All it does is ensure that a defined -value is passed to Apache2::Cookie->new. Show quoted text
> If it _is_ a bug in libapreq2, it should be > fixed, right?
Yes. Do you think you can convince the libapreq2 maintainers that it is a bug? Show quoted text
> Meanwhile, it's easy enough to workaround by just using CGI::Cookie.
Actually, I simply created my own version of Apache::Session::Wrapper with the fix, but it would be nice not to have to port every Apache::Session::Wrapper change forward into my new (and I was hoping, temporary) module. Would it help if I volunteered as a comaintainer for Apache::Session::Wrapper? Incidentally, you already protect against passing any other undefined values to Apache2::Cookie->new in _bake_cookie. Protecting the -value argument in the same way is as effective as my suggested fix, like: my $cookie = $self->{cookie_class}->new ( @{ $self->{new_cookie_args} }, -name => $self->{cookie_name}, ( defined $self->{session_id} ? ( -value => $self->{session_id} ) : () ), ( defined $expires ? ( -expires => $expires ) : () ), ( defined $domain ? ( -domain => $domain ) : () ), -path => $self->{cookie_path}, -secure => $self->{cookie_secure}, ); Instead of the current: my $cookie = $self->{cookie_class}->new ( @{ $self->{new_cookie_args} }, -name => $self->{cookie_name}, -value => $self->{session_id}, ( defined $expires ? ( -expires => $expires ) : () ), ( defined $domain ? ( -domain => $domain ) : () ), -path => $self->{cookie_path}, -secure => $self->{cookie_secure}, ); Thanks again,
On Mon Sep 18 11:40:33 2006, DPRICE wrote: Show quoted text
> Incidentally, you already protect against passing any other undefined > values to Apache2::Cookie->new in _bake_cookie. Protecting the -value > argument in the same way is as effective as my suggested fix, like:
Excuse me, I misremembered my original fix (expiring the cookie before deleting the session ID was my second fix, which I though was better for being shorter and making more sense). Passing no -value at all has the same effect as passing an undefined value for -value. This was my original fix before I settled on the patch I actually attached: ( defined $self->{session_id} ? ( -value => $self->{session_id} ) : ( -value => '' ) ), I still like my expire then delete patch better.
Subject: Re: [rt.cpan.org #20992] _bake_cookie sets empty (undef?) value when deleting sessions
Date: Mon, 18 Sep 2006 11:31:51 -0500 (CDT)
To: "Derek R. Price via RT" <bug-Apache-Session-Wrapper [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Mon, 18 Sep 2006, Derek R. Price via RT wrote: Show quoted text
>> Incidentally, you already protect against passing any other undefined >> values to Apache2::Cookie->new in _bake_cookie. Protecting the -value >> argument in the same way is as effective as my suggested fix, like:
> > Excuse me, I misremembered my original fix (expiring the cookie before > deleting the session ID was my second fix, which I though was better for > being shorter and making more sense). Passing no -value at all has the > same effect as passing an undefined value for -value. This was my > original fix before I settled on the patch I actually attached: > > > ( defined $self->{session_id} > ? ( -value => $self->{session_id} ) > : ( -value => '' ) > ),
I just came up with a similar fix myself. Show quoted text
> I still like my expire then delete patch better.
I don't. It works around the bug by changing code that's not local to where the problem manifests. That's what I meant when I said it would be something I'd have to maintain going forward. I'd have a change in one spot which works around a bug in an entirely non-obvious way.
Subject: Re: [rt.cpan.org #20992] _bake_cookie sets empty (undef?) value when deleting sessions
Date: Mon, 18 Sep 2006 10:47:34 -0500 (CDT)
To: "Derek R. Price via RT" <bug-Apache-Session-Wrapper [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Mon, 18 Sep 2006, Derek R. Price via RT wrote: Show quoted text
> Yes. Do you think you can convince the libapreq2 maintainers that it is > a bug?
I think I can. I know them reasonably well. Show quoted text
> Incidentally, you already protect against passing any other undefined > values to Apache2::Cookie->new in _bake_cookie. Protecting the -value > argument in the same way is as effective as my suggested fix, like: > > my $cookie = > $self->{cookie_class}->new > ( @{ $self->{new_cookie_args} }, > -name => $self->{cookie_name}, > ( defined $self->{session_id} > ? ( -value => $self->{session_id} ) > : () > ),
Ah, this I like much better. It fits in with the existing code well. I have to test that it works ok for Apache::Cookie & CGI::Cookie as well.
On Mon Sep 18 12:36:26 2006, autarch@urth.org wrote: Show quoted text
> On Mon, 18 Sep 2006, Derek R. Price via RT wrote:
> > ( defined $self->{session_id} > > ? ( -value => $self->{session_id} ) > > : ( -value => '' ) > > ),
> > I just came up with a similar fix myself.
Sorry if it's a silly question, but I was thinking that my previous posts may have been worded somewhat unclearly and the ordering of your responses confused me: something like the above fix is the one you are testing, correct? It is the one that I found that works with A2::C... Show quoted text
> > I still like my expire then delete patch better.
> > I don't. It works around the bug by changing code that's not local to > where the problem manifests. That's what I meant when I said it would be > something I'd have to maintain going forward. I'd have a change in one > spot which works around a bug in an entirely non-obvious way.
Okay, I can see the logic of this. Thanks. Show quoted text
> > Yes. Do you think you can convince the libapreq2 maintainers that it is > > a bug?
> > I think I can. I know them reasonably well.
I cc'd you on my initial report(s) to modperl@perl.apache.org. Hopefully that was the correct list. You should have the emails already, assuming your spam filter didn't eat my messages. Show quoted text
> Ah, this I like much better. It fits in with the existing code well. I > have to test that it works ok for Apache::Cookie & CGI::Cookie as well.
Great! I'm looking forward to the fresh release! Thanks again,