Subject: | Win32::OLE causes "Free to wrong pool" |
Distribution: libwin32-0.24 (Win32::OLE 1.702 and 1.502)
Perl-Version: v5.8.4 built for MSWin32-x86-multi-thread
OS: Windows 2000, Service Pack 4
The following code:
<Code>
use threads;
use Win32::OLE;
my $thread = threads->new( sub {
sleep 1; print "thread begin\n";
sleep 2; print "thread end\n";
});
sleep 2; print "join\n";
$thread->join;
print "joined\n";
sleep 2; print "undef\n";
$thread = undef;
sleep 2; print "end\n";
</Code>
produces the error: Free to wrong pool 15d54f0 not 15d41f0 during global destruction.
The offending statement is: $thread = undef;
The debugger tracks down the error to ole.xs line 3309
<ole.xs>
static void
AtExit(pTHX_ void *pVoid)
{
PERINTERP *pInterp = (PERINTERP*)pVoid;
DeleteCriticalSection(&g_CriticalSection);
if (g_hOLE32)
FreeLibrary(g_hOLE32);
if (g_hHHCTRL)
FreeLibrary(g_hHHCTRL);
#ifdef PERL_IMPLICIT_CONTEXT
Safefree(pInterp); /* line 3309 */
#endif
DBG(("AtExit done\n"));
} /* AtExit */
</ole.xs>