This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
stop gensyming when vivifying IO handles
When open() is given as a handle a scalar with undef value, the rv2gv
op creates a new glob for the I/O handle, and mutates the scalar to
contain an RV referencing the glob. This is documented behaviour.
The question arises of what GvNAME the glob should have. There's some
compile-time logic that spots that this might happen, and if the handle
expression is simple enough it stores in the pad a name representing
that expression, and rv2gv uses that for the GvNAME. But if no name
was supplied by that route then rv2gv was using newGVgen() to generate
the glob. That succeeds in giving it some kind of name, but has the
unwanted side effect of interning the glob in the stash under that name.
From the user's point of view, that creates a phantom reference to the
glob, which means that killing the RV doesn't remove the last reference
to the glob and so doesn't close the handle.
Instead of gensyming, just create an uninterned glob and give it a
fixed GvNAME. Fixes [perl #115814].