Skip to content

Conversation

@mikkoi
Copy link

@mikkoi mikkoi commented Nov 19, 2023

I am developing a testing tool which creates testing resources and then collects them when their reference count goes to zero. This means my code has a lot of activity in DESTRUCT phase. Often the DESTROY methods get executed only at the end of the program. So they go into global destruction. I was often receiving these errors:

(in cleanup) Log::Any::Proxy requires an 'adapter' parameter at [..]/Log/Any/Proxy.pm

... but not every time!

When I specifically reclaimed my objects by undef'ing them or by letting them fall out of subroutine scope, the problem disappeared.

Global Destruction

The order in which objects are destroyed during the global destruction before the program exits is unpredictable. This means that any objects contained by your object may already have been destroyed. You should check that a contained object is defined before calling a method on it:

-- https://perldoc.perl.org/perlobj#Global-Destruction

Global Destruction

The order in which objects are destroyed during the global destruction before
the program exits is unpredictable. This means that any objects contained
by your object may already have been destroyed. You should check that
a contained object is defined before calling a method on it:

https://perldoc.perl.org/perlobj#Global-Destruction

Signed-off-by: Mikko Koivunalho <mikkoi@cpan.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant