This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #118627] Don’t do COW when creating ${"_<-e"}[0]
The lexer does not expect PL_linestr (an SV holding the current line
of Perl code being parsed) to do copy-on-write. It expects to be able
to manipulate that SV to its hearts content with impunity. The one
piece of code that can cause it to do that is S_update_debugger_info,
when called with a SV for the first argument. The only time it is
called that way is for line 0 of the main script, containing state-
ments generated from command line arguments (e.g., ‘use strict’ from
‘-Mstrict’), and it is called with PL_linestr as its argument.
If ${"_<-e"}[0] ends up sharing the buffer with PL_linestr, bad things
will happen, as the lexer is going to continue to modify that buffer.
Usually we get this:
$ ./perl -It/lib -d:switchd_empty -e'print @{"_<-e"}' |less
^@se Devel::switchd_empty;
print @{"_<-e"}
So force S_update_debugger_info to do a non-COW copy.