Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another self-modifyingloop bug #6533

Open
p5pRT opened this issue May 24, 2003 · 5 comments
Open

Another self-modifyingloop bug #6533

p5pRT opened this issue May 24, 2003 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented May 24, 2003

Migrated from rt.perl.org#22312 (status was 'open')

Searchable as RT22312$

@p5pRT
Copy link
Author

p5pRT commented May 24, 2003

From perl-5.8.0@ton.iguana.be

Created by perl-5.8.0@ton.iguana.be

perl -e 'map{@​a=($_+=0)x$_}@​a=/\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.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.0:

Configured by ton at Tue Nov 12 01:56:18 CET 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.19, archname=i686-linux-thread-multi-64int-ld
    uname='linux quasar 2.4.19 #5 wed oct 2 02:34:25 cest 2002 i686 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=define
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -fomit-frame-pointer',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.3 20010315 (release)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -ldb -ldl -lm -lpthread -lc -lposix -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lposix -lcrypt -lutil
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.4'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.0:
    /usr/lib/perl5/5.8.0/i686-linux-thread-multi-64int-ld
    /usr/lib/perl5/5.8.0
    /usr/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi-64int-ld
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl
    .


Environment for perl v5.8.0:
    HOME=/home/ton
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ton/bin.Linux:/home/ton/bin:/home/ton/bin.SampleSetup:/usr/local/bin:/usr/local/sbin:/usr/local/jre/bin:/home/oracle/product/9.0.1/bin:/usr/local/ar/bin:/usr/games/bin:/usr/X11R6/bin:/usr/share/bin:/usr/bin:/usr/sbin:/bin:/sbin:.
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2005

From @schwern

[perl-5.8.0@​ton.iguana.be - Sat May 24 14​:07​:05 2003]​:

perl -e 'map{@​a=($_+=0)x$_}@​a=/\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 bleadperl@​25156. 5.6.2, 5.5.4 and
5.4.5 don't segfault.

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2005

From @iabyn

On Sun, Jul 17, 2005 at 03​:55​:28PM -0700, Michael G Schwern via RT wrote​:

[perl-5.8.0@​ton.iguana.be - Sat May 24 14​:07​:05 2003]​:

perl -e 'map{@​a=($_+=0)x$_}@​a=/\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 bleadperl@​25156. 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).

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2005

From @schwern

On Mon, Jul 18, 2005 at 08​:37​:14PM +0100, Dave Mitchell wrote​:

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

A good rule of thumb is "Perl should never kill perl" and any marginal
slow down is worth hanging onto that.

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern
ROCKS FALL! EVERYONE DIES!
  http​://www.somethingpositive.net/sp05032002.shtml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants