summaryrefslogtreecommitdiff
path: root/av.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-18 08:50:02 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-18 08:54:08 -0700
commitaf80dd863acea8450a9f41ae03645f4d69dad091 (patch)
tree3ba1f299e617fd42c8d50d260b0ab76a494e6eeb /av.h
parent7530120a7b187fc2f7598980ffae1d58f41c2cd7 (diff)
downloadperl-af80dd863acea8450a9f41ae03645f4d69dad091.tar.gz
[perl #97020] Carp (actually caller) leaking memory
Commit eff7e72c3 (Detect incomplete caller overrides in Carp) used this little trick for detecting a @DB::args that an overridden caller() failed to set: + @args = \$i; # A sentinal, which no-one else has the address of But there is a bug in caller(). The first time caller tries to write to @DB::args, it calls Perl_init_dbargs first. That function checks whether @DB::args is AvREAL, in case someone has assigned to it, and takes appropriate measures. But caller doesn’t bother calling Perl_init_dbargs more than once. So manually-assigned items in @DB::args would leak, starting with the *second* call to caller. Commit eff7e72c3 triggered that bug, resulting in a regression in Carp, in that it started leaking. eff7e72c3 was backported to 5.12.2 with commit 97705941a4, so in both 5.12 and 5.14 Carp is affected. This bug (the caller bug, not Carp’s triggering thereof) also affects any caller overrides that set @DB::args themselves, if there are alternate calls to the overridden caller and CORE::caller. This commit fixes that by changing the if (!PL_dbargs) condition in pp_caller to if (!PL_dbargs || AvREAL(PL_dbargs)). I.e., if @args is either uninitialised or AvREAL then call Perl_init_dbargs. Perl_init_dbargs also has a bug in it, that this fixes: The array not only needs AvREAL turned off, but also AvREIFY turned on, so that assignments to it that occur after its initialisation turn AvREAL back on again. (In fact, Larry Wall added a comment suggesting this back in perl 5.000.)
Diffstat (limited to 'av.h')
-rw-r--r--av.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/av.h b/av.h
index 8b0e6563cb..8d18d25af1 100644
--- a/av.h
+++ b/av.h
@@ -28,7 +28,7 @@ struct xpvav {
* real if the array needs to be modified in some way. Functions that
* modify fake AVs check both flags to call av_reify() as appropriate.
*
- * Note that the Perl stack and @DB::args have neither flag set. (Thus,
+ * Note that the Perl stack has neither flag set. (Thus,
* items that go on the stack are never refcounted.)
*
* These internal details are subject to change any time. AV