Ensure adapter is available during global destruction #106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
... 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