[PATCH] Re: [BUG] Bad refcounting in Apache->push_handlers()

[prev] [thread] [next] [Date index for 2005/03/31]

From: Dominique Quatravaux
Subject: [PATCH] Re: [BUG] Bad refcounting in Apache->push_handlers()
Date: 14:26 on 31 Mar 2005
--9zSXsLTf0vkW971A
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

> Any chance you could add a test to the modperl2 test suite that I can=20
> reproduce the problem with?

I finally got around to doing that, sorry for the delay. Here is a new
test case, with inspiration from TestHooks::inlined_handlers.

Warning: since Apache->server->push_handlers() needs to operate at the
global server-config level, once this patch is applied, the *entire*
test suite mostly stops working :-] However, I am confident that once
the bug is gone this patch will no longer be intrusive, because when I
un-inline the sub (there is a commented-out line to that effect in the
test case file), the test suite passes correctly as a whole.

Regards,

diff --exclude .svn -Naur mod_perl-2.ORIG/t/hooks/TestHooks/inlined_handler=
s_server_wide.pm mod_perl-2/t/hooks/TestHooks/inlined_handlers_server_wide.=
pm
--- mod_perl-2.ORIG/t/hooks/TestHooks/inlined_handlers_server_wide.pm	1970-=
01-01 01:00:00.000000000 +0100
+++ mod_perl-2/t/hooks/TestHooks/inlined_handlers_server_wide.pm	2005-03-31=
 16:20:20.000000000 +0200
@@ -0,0 +1,48 @@
+package TestHooks::inlined_handlers_server_wide;
+
+# this test exercises Apache handlers as anonymous subs, installed
+# using Apache->server->push_handlers() at mod_perl initialization
+# time.
+# Previously there was a refcounting bug there, similar to the
+# one described in inlined_handlers.pm
+
+use strict;
+use warnings FATAL =3D> 'all';
+
+use Apache2::RequestIO ();
+use Apache2::ServerUtil ();
+use Apache2::Const -compile =3D> qw(OK DECLINED);
+
+our $answer =3D "not ok 1\n";
+
+sub test_waz_zere {
+    my ($r) =3D @_;
+    $r->notes->set("test_waz_zere", 1);
+    Apache2::DECLINED;
+}
+
+BEGIN { if ($ENV{MOD_PERL}) {
+## This works (non-inlined handler):
+#    Apache2->server->push_handlers(PerlFixupHandler =3D> \&test_waz_zere =
);
+## This did not work as of Subversion r159573:
+    Apache2->server->push_handlers(PerlFixupHandler =3D> sub { test_waz_ze=
re() });
+} }
+
+sub handler {
+    my $r =3D shift;
+
+    $r->print("1..1\n");
+    $r->print($r->notes->get("test_waz_zere") ? "ok 1\n" :
+             "not ok 1\n");
+    Apache2::OK;
+}
+
+1;
+__DATA__
+<NoAutoConfig>
+    PerlModule TestHooks::inlined_handlers_server_wide
+  <Location /TestHooks__inlined_handlers_server_wide>
+      SetHandler modperl
+      PerlResponseHandler TestHooks::inlined_handlers_server_wide
+  </Location>
+</NoAutoConfig>


--=20
Dominique QUATRAVAUX                           Ing=E9nieur senior
01 44 42 00 08                                 IDEALX


--9zSXsLTf0vkW971A
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCTAicMJAKAU3mjcsRAt1OAKCLwf/fDoVim+/GyEO1YjuWl69IBwCfcgFA
K+JS/aJbiARV/XDsysZNbGc=
=MEIb
-----END PGP SIGNATURE-----

--9zSXsLTf0vkW971A--

[BUG] Bad refcounting in Apache->push_handlers()
Dominique Quatravaux 12:28 on 09 Mar 2005

[PATCH] Re: [BUG] Bad refcounting in Apache->push_handlers()
Dominique Quatravaux 14:26 on 31 Mar 2005

Generated at 14:43 on 11 Apr 2005 by mariachi v0.52