develooper Front page | perl.perl5.porters | Postings from September 2000

[ID 20000929.002] Self-tied arrays cause core dump

From:
Alan Burlison
Date:
September 29, 2000 16:20
Subject:
[ID 20000929.002] Self-tied arrays cause core dump
Message ID:
200009292320.e8TNKWm111757@mower.uk.sun.com

This is a bug report for perl from alanbur@mower.uk.sun.com,
generated with the help of perlbug 1.28 running under perl v5.6.0.


-----------------------------------------------------------------
[Please enter your report here]

Self-tied arrays cause core dumps.  With the following code:

package MyTie;
sub new
{
my ($class) = @_;
my @self;
tie(@self, $class, \@self);
return(\@self);
}
sub TIEARRAY
{
print("TIEARRAY @_\n");
bless $_[1], $_[0]
}
sub FETCH
{
print("FETCH @_\n");
return($_[0]->[$_[1]]);
}
package main;
my $tie = MyTie->new();
my $val = $tie->[0];

This happens:

Deep recursion on subroutine "MyTie::FETCH" at bug line 23.
TIEARRAY MyTie ARRAY(0x44818)
FETCH MyTie=ARRAY(0x44818) 0
FETCH MyTie=ARRAY(0x44818) 0
FETCH MyTie=ARRAY(0x44818) 0
FETCH MyTie=ARRAY(0x44818) 0
FETCH MyTie=ARRAY(0x44818) 0
FETCH MyTie=ARRAY(0x44818) 0
FETCH MyTie=ARRAY(0x44818) 0
FETCH MyTie=ARRAY(0x44818) 0

[many identical lines snipped]

Segmentation Fault(coredump)

If the line

   tie(@self, $class, \@self);

is changed to

   my @tied;
   tie(@self, $class, \@tied);

The problem doesn't occur.  This also happens in 5.005_03 and 5.7.0.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=high
---
Site configuration information for perl v5.6.0:

Configured by alanbur at Thu Sep 14 15:49:46 BST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.9, archname=sun4-solaris-multi-64int
    uname='sunos mower 5.9 s81_21 sun4u sparc sunw,ultra-60 '
    config_args='-dsOE -Dprefix=/home1/software/perl/debug -Dinstallprefix=/home1/software/perl/debug -Dsiteprefix=/home1/software/perl/debug -Doptimize=-g -Duseshrplib -Uusemymalloc -Ubincompat5005 -Duse64bitint -Dusemultiplicity -Accflags=-DPURIFY'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=define
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=
    cppflags='-DPURIFY -DDEBUGGING -I/usr/local/include'
    ccflags ='-DPURIFY -DDEBUGGING -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib -L/opt/SUNWspro/WS6/lib '
    libpth=/usr/local/lib /opt/SUNWspro/WS6/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -R /home1/software/perl/debug/lib/5.6.0/sun4-solaris-multi-64int/CORE'
    cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib -L/opt/SUNWspro/WS6/lib'

Locally applied patches:
    

---
@INC for perl v5.6.0:
    /home1/software/perl/debug/lib/5.6.0/sun4-solaris-multi-64int
    /home1/software/perl/debug/lib/5.6.0
    /home1/software/perl/debug/lib/site_perl/5.6.0/sun4-solaris-multi-64int
    /home1/software/perl/debug/lib/site_perl/5.6.0
    /home1/software/perl/debug/lib/site_perl
    .

---
Environment for perl v5.6.0:
    HOME=/home1/alanbur
    LANG=C
    LANGUAGE (unset)
    LC_COLLATE=en_GB.ISO8859-1
    LC_CTYPE=en_GB.ISO8859-1
    LC_MESSAGES=C
    LC_MONETARY=en_GB.ISO8859-1
    LC_NUMERIC=en_GB.ISO8859-1
    LC_TIME=en_GB.ISO8859-1
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/ccs/bin:/home1/software/perl/debug/bin:/usr/bin:/usr/local/bin:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/dt/bin:/usr/openwin/bin:/home1/alanbur/bin:.:/usr/dist/exe:/usr/dist/local/exe
    PERL_BADLANG (unset)
    SHELL=/bin/ksh




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About