develooper Front page | perl.perl5.porters | Postings from November 2004

[perl #32714] Objects destroyed in the wrong order during global destruction

Mark-Jason Dominus
November 30, 2004 07:23
[perl #32714] Objects destroyed in the wrong order during global destruction
Message ID:
# New Ticket Created by  Mark-Jason Dominus 
# Please include the string:  [perl #32714]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.34 running under perl v5.8.0.

[Please enter your report here]

The following program manufactures an "Outer" object that contains an
"Inner" subobject.  The outer object is destroyed during the global
destruction phase, but at the time that Outer::DESTOY is called, the
outer object has been corrupted.  Its inner object is already gone,
and its value in the outer hash has been set to "undef".


        use Data::Dumper;

        sub Outer::new
                my $self = {subobject => bless(["Hey, where did I go?"], "Inner")};
                bless($self, 'Outer');

        sub Outer::DESTROY
          warn "Hey, where is my subobject?" unless defined $_[0]{subobject};

        $helper = new Outer;

        sub test
          print STDERR "TEST: $helper";

Here Outer::DESTROY is expecting that its subobject will still be
intact at the time the outer object is destroyed.  It plaintively asks
about the location of its missing inner object:

        Hey, where is my subobject? at helper line 13 during global destruction.

The bug is highly peturbable.  Removing the (unused) "use
Data::Dumper" statement makes it go away, as does removing the
(unused) "test" subroutine or the (unused) "print" statement inside of

This bug was reported by Christoph Haas under 5.8.4; his bug report
should be coming through soon, if it has not already.

[Please do not change anything below this line]
Site configuration information for perl v5.8.0:

Configured by mjd at Thu Apr 17 11:57:37 EDT 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
    osname=linux, osvers=2.4.2-2, archname=i586-linux
    uname='linux 2.4.2-2 #1 sun apr 8 19:37:14 edt 2001 i586 unknown '
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-81)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, 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 -lgdbm -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  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:

Environment for perl v5.8.0:
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About