-
Notifications
You must be signed in to change notification settings - Fork 567
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
File handle doesn't close when out of scope due to \shift #15052
Comments
From @toddrCreated by @toddrWhile preparing to move to 5.22, we noticed a bug which manifests due This bisects to 7bdb4ff introduced in 5.21.4 If you use $_[0] directly in the subroutine instead of assging $rv to NOTE: The use of \shift is also currently breaking Devel::Cover very Example code also used to bisect: ===== foo.pl use B qw/svref_2object/; my $file = "/tmp/file"; sub nested2 { sub nested1 { # The ref count on $fh should be 1 now..? unlink $file; $refcount == 1 or die("Ref count should have been 1 after returning # If you uncomment this line and comment the above die, -z is false in
|
From @ap* Todd Rinaldo <perlbug-followup@perl.org> [2015-11-18 19:45]:
$ perldoc -f system | perl -00ne 'print if /flush/' |
The RT System itself - Status changed from 'new' to 'open' |
From @toddrOn Wed Nov 18 17:02:21 2015, aristotle wrote:
Thanks! That totally explains the flush. This probably means the file handle is not freed until global destruction. |
From @iabynOn Wed, Nov 18, 2015 at 10:39:46AM -0800, Todd Rinaldo wrote:
Its not so much an issue with \shift as an issue with anything (such as use Devel::Peek; my $fh; my $fh2; which gives ... ... Note that the first one has an extra ref count, which is added by the The real issue is how the new typeglob is created, and whether it's When it's known at compile time what the name the variable that will be The two important thing about all those names is that they are determined On the other hand, if a name isn't determined at compile time, as is the I think the easiest fix for this is to, for the latter case, treat it like This is an area I'm not too familiar with, so I don't know whether there
Well I just tried it on 5.44.4, 5.20.0 and 5.22.0; I saw problems with the -- |
From @cpansproutOn Nov 19, 2015, at 6:15 AM, Dave Mitchell <davem@iabyn.com> wrote:
It has been on my ever-growing to-do list for some time to consider whether _GEN_NNN should every be added to the stash. Every time that happens, it’s a leak. Does anybody ever access them by name? Whether this should be fixed by (a) switching everything to __ANONIO__ or by (b) using _GEN_NNN without adding it to the stash I cannot say. I don’t understand why we ended up with an inconsistency in the first place. (Digging in history to find out which one came first might shed some light on it.) Using _GEN_* does allow different handles to be distinguished in error messages, but __ANONIO__ certainly seems cleaner. For backward-compatibility, though, maybe option b is the best choice.
Wow! |
From @toddrOn Thu, 19 Nov 2015 09:20:06 -0800, sprout wrote:
FYI, We're in the process of submitting a change to Perl::Critic to discourage the use of \shift. Perl-Critic/Perl-Critic#837 At this point we've now got 4 major versions of perl with this issue. |
FYI Perl::Critic now warns people not to do this in code because of this leak. |
Migrated from rt.perl.org#126676 (status was 'open')
Searchable as RT126676$
The text was updated successfully, but these errors were encountered: