Closed p5pRT closed 20 years ago
$ perl -we 'use overload q!""!\, sub {undef}; $_ = join ""\, bless []' Use of uninitialized value in join at -e line 1. Use of uninitialized value in join at -e line 1.
This problem was fixed for the SvGMAGICAL case\, but not for overload. (The problem is do_join scans through the sv's being joined to get a length to pre-grow the target sv. In the process\, it invokes the magic twice. See the archives under this subject in 1998-04 and under "Possible solution of join() double-magic?" in 1998-06.)
Are there additional cases besides overload? Seems like we need a macro SvVOLATILE or some such to properly localise the cases do_join needs to check for in sv.[ch].
Or maybe correcting this would be more expensive than just growing multiple times\, and the pre-grow check should be scrapped in favor of some form of prospective growing in the catsv loop.
In \200008080606\.e7866sL23632@​garcia\.efn\.org\, sthoenna@efn.org writes: :$ perl -we 'use overload q!""!\, sub {undef}; $_ = join ""\, bless []' :Use of uninitialized value in join at -e line 1. :Use of uninitialized value in join at -e line 1. : :This problem was fixed for the SvGMAGICAL case\, but not for overload. :(The problem is do_join scans through the sv's being joined to get a :length to pre-grow the target sv. In the process\, it invokes the :magic twice. See the archives under this subject in 1998-04 and :under "Possible solution of join() double-magic?" in 1998-06.) : :Are there additional cases besides overload? Seems like we need :a macro SvVOLATILE or some such to properly localise the cases do_join :needs to check for in sv.[ch]. : :Or maybe correcting this would be more expensive than just growing :multiple times\, and the pre-grow check should be scrapped in favor :of some form of prospective growing in the catsv loop.
Scrapping the pre-check was the solution I proposed way back when; that was deemed unacceptable. I feel there ought to be a way to effect a more generic solution\, so that any argument's magic is fetched only once per op: this should allow us to simplify the code throughout\, and use more consistent mechanisms. I can't see how to do it however\, particularly given the possibility of (eg) C\<join '\,'\, $tiedrand\, $tiedrand>.
Hugo
sthoenna@efn.org wrote
Or maybe correcting this would be more expensive than just growing multiple times\, and the pre-grow check should be scrapped in favor of some form of prospective growing in the catsv loop.
That optimisation is very important - see Ilya's remarks in the threads you quoted. And correcting it is zero cost\, since the two flags can be tested in one go.
So here's the patch\, for bleadperl. I noticed that the original fix didn't have any associated tests\, so I added some.
Mike Guy
On Tue\, Aug 08\, 2000 at 03:51:27PM +0100\, Mike Guy wrote:
sthoenna@efn.org wrote
Or maybe correcting this would be more expensive than just growing multiple times\, and the pre-grow check should be scrapped in favor of some form of prospective growing in the catsv loop.
That optimisation is very important - see Ilya's remarks in the threads you quoted. And correcting it is zero cost\, since the two flags can be tested in one go.
So here's the patch\, for bleadperl. I noticed that the original fix didn't have any associated tests\, so I added some.
Thanks\, applied.
Migrated from rt.perl.org#3656 (status was 'resolved')
Searchable as RT3656$