Menu

#3 Problems with cleanup code from 0.46 onwards

open
nobody
None
5
2004-09-15
2004-09-15
Anonymous
No

The cleanup code introduced in 0.46 can lead to
problems in other programs DESTROY function, since the
logger is still alive, but can no longer be called. If
a OO-package has something like

...
my $log = get_logger;
...

sub DESTROY {
if ($log) {
$log->debug(...);
}
}

Depending on the destruction implementation of the
perl-version this can lead to warnings like:
Use of uninitialized value in subroutine entry at
/home/heikok/tmp/perl5/Log/Log4perl/Logger.pm line 689
during global destruction.

since $log->debug still can be called, while
$log->{is_debug} might have been cleaned up.

Possible solutions:
a) check for the existence of $log->{is_*} in the
construction of the $log->functions
b) why do you need to cleanup the hash-keys?
c) create a interface so that users can check if the
logger still is alive. I'm currently using:
if ($log && scalar keys %$log)
but this goes IMHO to deep into the $log package. a
$log->is_alive would be much nicer

I haven't been able to reconstruct this problem in a
small case since it depends to strongly on the order of
the garbage-collector of perl. I found this bug in the
SPOPS package (0.87) on CPAN.

Heiko

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.