Subject: | "Free to wrong pool" error |
I got the following error while using Log::Dispatch::Win32EventLog
Free to wrong pool 1f84a70 not 332bb0 at
D:/product/perl/site/lib/Win32/EventLog.pm line 110 during global
destruction.
============
This seems to be connected to threading somehow. The following nonsense
script reproduces the error:
#!perl -w
use strict;
use threads;
use Log::Dispatch::File;
use Log::Dispatch::Handle;
use Log::Dispatch::Screen;
use Log::Dispatch::Win32EventLog;
$| = !0;
my($logger) = Log::Dispatch->new;
$logger->add(Log::Dispatch::Screen->new(name => 'console',
min_level => 'debug',
max_level => 'info',
stderr => 0));
$logger->add(Log::Dispatch::Screen->new(name => 'stderr',
min_level => 'notice',
stderr => 1));
# comment this out and the program runs fine
$logger->add(Log::Dispatch::Win32EventLog->new(name => 'event_log',
min_level => 'notice',
source => 'RmCtl'));
# uncomment the thread bit to get the program to crash
foreach my $level (qw(debug info notice warning error)) {
logit($level);
# my($thread) = threads->new(\&logit, $level, 5); $thread->join;
}
sub logit
{
my($level, $sleep) = @_;
print time . " ($level) ";
sleep(rand($sleep) + 1) if $sleep;
$logger->log(level => $level, message => "[\U$level\E] test message ("
. time . ")\n");
}
============
Output with the program run as above:
D:\>perl logtest.pl
1189448714 (debug) [DEBUG] test message (1189448714)
1189448714 (info) [INFO] test message (1189448714)
1189448714 (notice) [NOTICE] test message (1189448714)
1189448714 (warning) [WARNING] test message (1189448714)
1189448714 (error) [ERROR] test message (1189448714)
Output with the first logit() commented out, and the threads->new
uncommented:
D:\>perl logtest.pl
1189448750 (debug) [DEBUG] test message (1189448751)
Free to wrong pool 19a1568 not 334280 at
D:/product/perl/site/lib/Win32/EventLog
.pm line 110 during global destruction.
(which, interestingly, shouldn't even be called, as both debug and info
are below the minimum level.)
And finally, output with the threads on but the call to set up the
Log::Dispatch::Win32EventLog commented out:
D:\>perl logtest.pl
1189448850 (debug) [DEBUG] test message (1189448855)
1189448855 (info) [INFO] test message (1189448860)
1189448860 (notice) [NOTICE] test message (1189448864)
1189448864 (warning) [WARNING] test message (1189448868)
1189448868 (error) [ERROR] test message (1189448872)
============
This is perl, v5.8.7 built for MSWin32-x86-multi-thread
(with 14 registered patches, see perl -V for more detail)
Copyright 1987-2005, Larry Wall
Binary build 815 [211909] provided by ActiveState http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Nov 2 2005 08:44:52
============
OS: Win XP Pro SP 2
============
The above error results in the following message in the Application log:
Faulting application perl.exe, version 5.8.7.815, faulting module
perl58.dll, version 5.8.7.815, fault address 0x00089af4.
============
Let me know if there's anything else I can provide to help track this down.