On Sun, Jul 17, 2005 at 03:55:28PM -0700, Michael G Schwern via RT wrote:
> > [EMAIL PROTECTED] - Sat May 24 14:07:05 2003]:
> > 
> > perl -e '[EMAIL PROTECTED]($_+=0)[EMAIL PROTECTED]/\B./g for 1100..2000'
> > Segmentation fault (core dumped)
> > 
> > A bit different from the normal ones which mostly involve
> > modifying a "for" loop variable. "map" usually can take
> > these abuses.
> 
> Confirmed segfaulting in 5.8.6 and [EMAIL PROTECTED]  5.6.2, 5.5.4 and
> 5.4.5 don't segfault.

Not a lot we an do about this except to possibly do for 'map'/'grep' what
I did with 'for'; and that is to put a test in for a freed value, and if
so, bail out. It's not perfect, but it's usually better than an segfault:

    $ ./perl -we '@a=1..9; @a = () for @a,1'
    Use of freed value in iteration at -e line 1.
    $

The only question is whether it's worth the small slowdown of testing the
refcnt of $_ at each iteration?


-- 
You live and learn (although usually you just live).

Reply via email to