I'm experiencing behavior that was not expected, and I'm wondering if this is "normal".
I have a "session" object that has a "has a" relationship with CGI::Session.
If I make sure to undef my object before the program ends, then everything is fine.
However, if I don't specifically undef my session object... and instead rely on the default garbage collection... it looks like the CGI::Session object I'm using gets destroyed BEFORE my session object gets destroyed.
It would seem to me that there should still be a reference count to the CGI::Session object as long as my object exists and that my session object would be destroyed first. Isn't this the way it is supposed to happen?
I managed to squeak out a diagnostic message that said
DESTROY created new reference to dead object
and have litterd my code with diagnostic print statements. Everything is fine until I make a call to the CGI::Session's param method and then the program spits out:
Can't call method "param" on an undefined value...
I am about to write a "minimal" object to try and replicate (and hopefully fix) the problem. But, I was wondering if I'm just totally mixed up on Perl's garbage collection.
UPDATE: By adding a print statement to my destructor and the destructor in CGI::Session I can definitely say that CGI::Session is being destroyed before my object is.
UPDATE 2: I've posted code that demonstrates the problem in a new journal entry.