Custom clone() and free() function pointers for ManagedStruct

Mark Glines mark at glines.org
Wed Apr 8 14:14:36 UTC 2009


Hi,

I'm working on TT #18, trying to solve an issue with JIT segfaulting on
machines with nonexecutable heaps.  (As can be caused by Selinux and
possibly other similar systems.)  I'm starting with NCI JIT, once we get
that right we can switch over all the other JIT too.

So I've added the necessary "size" argument to various functions and got
mmap-based buffer allocation working.  The first problem I hit was that
the existing code blindly tries to call free() (rather than munmap) when
the ManagedStruct PMC referencing the buffer was garbage collected.
Which means we need a custom free() handler which does munmap() instead
of free() (with the proper "size" argument), and also a custom clone()
handler is needed for similar reasons.

Yesterday we had a design discussion in #parrot about this, mainly
revolving around which PMC to add the necessary functionality to.  We
(Santtu++ and I) had made a couple of patchsets which took different
approaches to the problem.  In the end, chromatic++ preferred to keep
using (and extending) ManagedStruct, and to keep the custom-free and
custom-clone features as generic as possible in the hopes that they'll
be reusable for other things later.  So I've reworked my previous set of
patches to do this.

That particular feature is implemented in
https://trac.parrot.org/parrot/attachment/ticket/18/02_managedstruct-free_func-attr.patch.txt
.  I would love to get that patch reviewed to make sure we're headed in
the right direction this time.  If needed, a subsequent patch (patch 03,
attached to the same ticket) provides an example of how to use the feature.

Mark


More information about the parrot-dev mailing list