develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #115814] open ${\$x} leaks

Thread Previous | Thread Next
From:
Zefram
Date:
December 10, 2017 01:52
Subject:
Re: [perl #115814] open ${\$x} leaks
Message ID:
20171210015202.GZ25404@fysh.org
Father Chrysostomos wrote:
>Is there any guarantee that a handle created like that will be accessible
>like this?

Quite the contrary.  perlfunc(1) describes the generated filehandle as
"anonymous", which would seem to preclude it being interned in the stash.
This description is applied to any case of an undef value being supplied;
there's no distinction corresponding to the difference between open($a)
and open(${\$a}).

For the glob to be sometimes interned is surprising
and undocumented.  It is surely a bug.  Fixed in commit
db9848c8d3fb321d27f38c1bd7992005a77ccfbc.

>newGVgen, which creates a new handle (with a name like _GEN_0), also
>adds it to the symbol table.  It is an API function.  Should it stop
>adding it to the symbol table?

It's not documented, and interning isn't a crazy thing to do, so I'd
take the behaviour to be definitive.  The bug isn't newGVgen() interning,
it's rv2gv using newGVgen().

But if most users of newGVgen() wouldn't be affected by it not interning,
that suggests that they don't actually want this behaviour, and so
newGVgen() is probably the wrong thing for them to use.  Tickets should
be filed against the individual CPAN distros telling them to do something
else.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About