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]
authorFather Chrysostomos <sprout@cpan.org>
Thu, 11 Jul 2013 20:13:58 +0000 (13:13 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 12 Jul 2013 00:47:53 +0000 (17:47 -0700)
commit4e917a04b786fbe31ab3ff95fbef9b0c7e6637c0
tree92f2b272a92521aad344d612c0a8904d218ef813
parentf556af6c048b2769e0a588d55ef54f5949171836
[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.
t/run/switchd.t
toke.c