CC: | perl5-porters [...] perl.org, zefram [...] fysh.org, rafl [...] debian.org, frank [...] wiles.org, rurban [...] x-ray.at, bug-Apache-DB [...] rt.cpan.org |
Subject: | [perl #101486] PL_curstash should be refcounted |
Date: | Sat, 22 Oct 2011 11:56:22 -0700 |
To: | "OtherRecipients of perl Ticket #101486":; |
From: | "Father Chrysostomos via RT" <perlbug-comment [...] perl.org> |
On Tue Oct 18 12:52:54 2011, frank@wiles.org wrote:
Show quoted text
> I'm actually hoping to find new maintainers for my CPAN projects as I
> no longer work in Perl. I'm happy to apply patches and put out a new
> release if someone doesn't want to take over the maintainership
> howeer.
I have a commit on the smoke-me/curstash branch
(<http://perl5.git.perl.org/perl.git/shortlog/refs/heads/smoke-me/curstash>)
that will be integrated into blead soon.
Attached is a patch for Apache::DB. Not having a mod_perl environment
set up, I can’t really test this, but I can confirm that it compiles.
If you want to test it before release of 5.15.5 (i.e., before blead’s
version number is bumped), you will have to tweak the version check to
use 5.15.4 instead.
diff -rup Apache-DB-0.14-yNQVbM/DB.xs Apache-DB-0.14-yNQVbM-copy/DB.xs
--- Apache-DB-0.14-yNQVbM/DB.xs 2008-04-27 14:52:40.000000000 -0700
+++ Apache-DB-0.14-yNQVbM-copy/DB.xs 2011-10-22 11:44:37.000000000 -0700
@@ -6,10 +6,26 @@
#define SIGINT 2
#endif
+#define HAVE_PERL(R, V, S) \
+ (PERL_REVISION > (R) || ( \
+ PERL_REVISION == (R) && ( \
+ PERL_VERSION > (V) || ( \
+ PERL_VERSION == (V) && PERL_SUBVERSION >= (S) \
+ ) \
+ ) \
+ ))
+
+#if HAVE_PERL(5,15,5)
+# define SET_CURSTASH(x) \
+ (SvREFCNT_dec(PL_curstash), PL_curstash = SvREFCNT_inc(x))
+#else
+# define SET_CURSTASH(x) (PL_curstash = (x))
+#endif
+
static void my_init_debugger()
{
dTHR;
- PL_curstash = PL_debstash;
+ SET_CURSTASH(PL_debstash);
PL_dbargs =
GvAV(gv_AVadd((gv_fetchpv("DB::args", GV_ADDMULTI, SVt_PVAV))));
AvREAL_off(PL_dbargs);
@@ -22,7 +38,7 @@ static void my_init_debugger()
sv_setiv(PL_DBtrace, 0);
PL_DBsignal = GvSV((gv_fetchpv("DB::signal", GV_ADDMULTI, SVt_PV)));
sv_setiv(PL_DBsignal, 0);
- PL_curstash = PL_defstash;
+ SET_CURSTASH(PL_defstash);
}