Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Keep It Simple, Stupid
 
PerlMonks  

(tye)Re: Oh my God! Tie killed Perl!

by tye (Cardinal)
on Jan 14, 2002 at 22:36 UTC ( #138651=note: print w/ replies, xml ) Need Help??


in reply to Oh my God! Tie killed Perl!

Just a quick note that globals get destroyed in somewhat random order and that can often result in references turning into undef in the middle of "global destruction". Actually, they are still references (because ref returns a true value), they just have an address of 0 (they return 0 in a numeric context), which Perl reports as "undef" when you actually try to use it.

I wish Perl would at least have an option to, during clean up, decrement the ref count on all globals, destroying things in the normal manner, and after that, would then go sweep up anything that was left over.

That only partially addresses one of your questions, but that was all I have time for at the moment. (:

Update: Hmm, you aren't using any globals so this probably isn't the problem, though. Hmm...

Oh, wait. You have hard-coded references to your lexical %x in your subroutines. This means that %x won't be freed until those subroutines are freed and subroutines don't get freed until "the end". Change your code so that \%x is passed in to TIEHASH (and keep the reference to it commented out in DESTROY) and see how that changes things.

        - tye (but my friends call me "Tye")


Comment on (tye)Re: Oh my God! Tie killed Perl!
Re: Oh my God! Tie killed Perl!
by jmcnamara (Monsignor) on Jan 15, 2002 at 15:24 UTC

    I wish Perl would at least have an option to, during clean up, decrement the ref count on all globals, destroying things in the normal manner, and after that, would then go sweep up anything that was left over.

    I think that this has been fixed, to some extent, in 5.7.2. The following is from the Changes file.

    [ 7991] By: jhi on 2000/12/05 15:52:34 Log: Subject: Re: [PATCH] The largest hoax of all times? From: Ilya Zakharevich <ilya@math.ohio-state.edu> Date: Tue, 5 Dec 2000 00:40:25 -0500 Message-ID: <20001205004025.A4050@monk.mps.ohio-state.edu +> ... Fix the unpredictable order of DESTROYs. ...
    The fix was also discussed in the p5p digest.

    Nevertheless, on 5.7.2 I still have problems with Perl objects that contain sub-objects which are destroyed too early. However, I am not sure if this is part of the same problem.

    --
    John.

      No, that patch fixes a completely different "problem" that never bothered me at all, something that I don't consider a "problem" much less a "bug".

      The patch causes unrelated objects to be destroyed in the reverse of the order in which they were created.

      The problem I'm talking about is that related objects (that is, objects where one object holds a reference to the other) can be destroyed in the wrong order if the objects manage to live until the "global destruction" phase of the Perl interpretter shutdown.

              - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://138651]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2014-04-16 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (432 votes), past polls