[Python-Dev] pymalloc killer

Tim Peters tim.one@comcast.net
Fri, 29 Mar 2002 19:12:50 -0500


[David Abrahams]
> OK, but I guess my question still holds: can't you just round down to
> find a supposed arena address,

No, and this is the point at which you get stuck.  The arena base address is
whatever the heck libc malloc returned when we asked for 256KB.  There's no
way to deduce that from the addresses *within* the arena.

> look up the index, and see if that arena is in the vector?

It would be possible to store both the arena index *and* the arena base
address in each pool header.  Then we could check that

    poolheader* p = pool_address(some_memory_address);
    if (p->arenaindex < narenas &&
        arenas[p->arenaindex] == p->arenabase) {
        it's a pymalloc address
    }
    else {
        it isn't
    }

I like that.  Thanks!