New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
goto refcount increased by one when using goto #16749
Comments
From @toddrCreated by @toddrWhile developing Test::MockFile across perls betwen 5.10.1 and 5.28, I've This showed up primarily when overriding CORE::GLOBAL::open and discovering The simplest example of this problem is: --- use B (); my $refcount; --- On 5.28, the refcount for $fh is 2. But in 5.20, the refcount is 1. I can make the problem go away by doing this instead of goto: return I also notice the problem doesn't manifest on 5.28 if I do this instead: --- use B (); BEGIN { my $count = 1; sub trynow { So this doesn't seem to be a global problem. Perl Info
|
From @toddrI was able to automatically bisect this to 7bdb4ff which first showed up in v5.21.10. commit 7bdb4ff (refs/bisect/bad) Fix refcounting in rv2gv when it calls newGVgen pp.c | 1 + |
The RT System itself - Status changed from 'new' to 'open' |
From @iabynOn Thu, Nov 15, 2018 at 10:38:36AM -0800, Todd Rinaldo (via RT) wrote:
Running the above I don't see that in 5.27.7 and above: $ perl5200 ~/tmp/p -- |
From @toddrWhich means it was fixed in: commit db9848c (refs/bisect/bad) stop gensyming when vivifying IO handles pp.c | 12 +++++------- |
From @toddrThe only other action I can see here is to make sure we have a test for this. I need to look into the tests some more. The tests added in that commit are a skip and I'm not clear if we'll detect the refcount issue the next time this happens. I'll try to check them later this week. |
From @tonycozOn Tue, 20 Nov 2018 08:14:16 -0800, todd.e.rinaldo@gmail.com wrote:
Something like the attached? Tony |
From @tonycoz0001-perl-133660-add-test-for-goto-sub-in-overload-leakin.patchFrom 88f17ff8910eefba68388fbf055d9d31f822c641 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 6 Feb 2019 15:42:10 +1100
Subject: (perl #133660) add test for goto &sub in overload leaking
The bug in this case was fixed in db9848c8d.
---
t/op/svleak.t | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/t/op/svleak.t b/t/op/svleak.t
index 3283c95cbf..bfa6747a02 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -15,7 +15,7 @@ BEGIN {
use Config;
-plan tests => 149;
+plan tests => 150;
# run some code N times. If the number of SVs at the end of loop N is
# greater than (N-1)*delta at the end of loop 1, we've got a leak
@@ -625,3 +625,23 @@ SKIP: {
sub Regex_Key_Leak { my ($r)= keys %rh; "foo"=~$r; }
leak 2, 0, \&Regex_Key_Leak,"RT #132892 - regex patterns should not leak";
}
+
+{
+ # perl #133660
+ fresh_perl_is(<<'PERL', "ok", {}, "check goto core sub doesn't leak");
+# done this way to avoid overloads for all of svleak.t
+use B;
+BEGIN {
+ *CORE::GLOBAL::open = sub (*;$@) {
+ goto \&CORE::open;
+ };
+}
+
+my $refcount;
+{
+ open(my $fh, '<', 'TEST');
+ my $sv = B::svref_2object($fh);
+ print $sv->REFCNT == 1 ? "ok" : "not ok";
+}
+PERL
+}
--
2.11.0
|
From @toddrOn Tue, 05 Feb 2019 20:42:46 -0800, tonyc wrote:
That's it! Fails on maint-5.26 as expected: # Failed test 142 - check goto core sub doesn't leak at ./test.pl line 1059 And passes on maint-5.28 ok 150 - check goto core sub doesn't leak I'll let you do the honors. Thanks, |
From @tonycozOn Thu, 07 Feb 2019 06:46:10 -0800, todd.e.rinaldo@gmail.com wrote:
Applied as ac6d259. Tony |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.30.0, this and 160 other issues have been Perl 5.30.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#133660 (status was 'resolved')
Searchable as RT133660$
The text was updated successfully, but these errors were encountered: