Yes I don't think the code I gave was very easy to understand - too many foos!

The style issues were mostly introduced by me paring down 20,000 lines of code to 40 (and the odd C++ programmer :)

Your example is not exactly the same as the issue I'm seeing, but your example is much clearer - based on that, the following does not crash:

package Foo; use strict; use XML::LibXML; use Scalar::Util qw/weaken/; use Data::Dumper; sub DESTROY { my $self=shift; warn "\n$self dtor"; } sub new { warn "\n".__PACKAGE__." xtor"; my $self = {}; bless $self, __PACKAGE__; my $parser = XML::LibXML->new(); my $confdoc = $parser->parse_string('<foo att1="val1"/>'); my $root = $confdoc->documentElement(); my @nodes = $root->findnodes('/*'); for my $n (@nodes){ for my $att ($n->attributes()) { my $foo = $att->nodeName; my ($key, $val) = (lc($att->nodeName), lc($att +->getValue)); warn "$key - $val"; } } warn __PACKAGE__." xtor COMPLETE"; return $self; } package user; sub DESTROY {Foo->new()} bless my $self=[] => __PACKAGE__; my $f=Foo->new();

but essentially the same code using a Foo.pm and crash.pl does:

#Foo.pm package Foo; use strict; use XML::LibXML; use Scalar::Util qw/weaken/; use Data::Dumper; sub DESTROY { my $self=shift; warn "\n$self dtor"; } sub new { warn "\n".__PACKAGE__." xtor"; my $self = {}; bless $self, __PACKAGE__; my $parser = XML::LibXML->new(); my $confdoc = $parser->parse_string('<foo att1="val1"/>'); my $root = $confdoc->documentElement(); my @nodes = $root->findnodes('/*'); for my $n (@nodes){ for my $att ($n->attributes()) { my $foo = $att->nodeName; my ($key, $val) = (lc($att->nodeName), lc($att +->getValue)); warn "$key - $val"; } } warn __PACKAGE__." xtor COMPLETE"; return $self; } 1;
#!/usr/bin/perl #this is crash.pl use Foo; package user; bless ($self=[]) => __PACKAGE__; $f=Foo->new(); sub DESTROY {Foo->new()}

In reply to Re^2: perl crash during global destruction by flipper
in thread perl crash during global destruction by flipper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.