This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Copy scalar refs returned from @INC filters
authorFather Chrysostomos <sprout@cpan.org>
Sat, 22 Jun 2013 08:16:22 +0000 (01:16 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 23 Jun 2013 06:16:41 +0000 (23:16 -0700)
commit9b7d7782b9990e579acbba430d00797bfb529804
tree43a98c0daea1f5833b6749f2cc2e943fff353e35
parentecff11eb0f000fc186c1b5652087c979947e4389
Copy scalar refs returned from @INC filters

This commit:

4464f08ea532be08ea7f0c44d0eb6e285a0c36fb is the first bad commit
commit 4464f08ea532be08ea7f0c44d0eb6e285a0c36fb
Author: Nicholas Clark <nick@ccl4.org>
Date:   Fri Oct 23 16:54:10 2009 +0100

    S_run_user_filter() can use the filter GV itself for the cache buffer.

    This saves allocating an extra SV head and body.

caused this:

$ perl -e '@INC = sub { \$_ }; eval { require foo }; $a = $_;'
Bizarre copy of IO in sassign at -e line 1.

Well, passing the existing string to filter_add causes that string
*itself* to be upgraded to SVt_PVIO, which is clearly not a good thing
if the caller can still reference it.  So we end up with $ bound to an
IO thingy.

And if the referent is a REGEXP, we get a crash during global destruc-
tion, or at least we did until the previous commit, which stopped
REGEXP->PVIO upgrades from being legal.  (Clearly they don’t work.)

The easiest way to fix this is to copy the string into a new scalar,
which then gets upgraded to PVIO.
pp_ctl.c
t/op/incfilter.t