On Wed, 16 Nov 2005, Steve Hay wrote:
[...]

> I should have said, though, that as well as the perl.exe crash I also
> get that old chestnut, the "Free to wrong pool" error.
>
> There have been discussions, and even patches, in the past about being
> able to reproduce these errors in non-Win32 land. One such discussion
> is this thread:
>
> http://marc.theaimsgroup.com/?t=107465400700004&r=1&w=2
>
> Message number 17 in that list contains a patch from Jan Dubois which
> Stas Bekman successfully made use of a few messages later. I don't
> think the patch was ever worked up into a state in which it could be
> applied, but it may be of some use whenever you next get an
> opportunity for unpaid pain fighting.

I think that patch is mostly in a state that could be applied.  The only
thing that should be added is some THX macro that can be used in the
cast expressions.

However, this particular patch only duplicates the error you get on
Windows when you free memory that belongs to a different context (THX).

In a later message I tried to add code that would catch the problem
earlier, when you allocate the memory in the wrong context.  It is
not always possible to detect this, but when you upgrade an SV, or
reallocate the buffer in a context that doesn't own the SV then your
are allocating the memory from the wrong pool.  Catching this is
will require quite a bit more work though.

So maybe at least the first patch should be committed to blead.
Let me know if I should rework it so it applies cleanly to current
blead (and come up with the missing THX macro).  There was also
a comment in the thread that the pool checking on Unix should
always be enabled when -DDEBUGGING is being used.  Is there
consensus on that, or is a separate symbol like PERL_TRACK_MEMPOOL
preferable?

Cheers,
-Jan



Reply via email to