I don't have a specific solution for you, just some observations.

The segfaults you see are almost certainly from double-freeing chunks of memory. Perl has its own memory management - in two flavors. One uses native malloc/free, the other a version provided by perl. Both are closely tied in to how perl provides storage to variables and and decides when it can take it back.

Your specific questions say you already appreciate the trouble this may cause.

You will probably need to carefully work both mm models in parallel, with two mallocs, two frees, and a separate memory arena for libgc-managed storage. You'll need to keep track of which pointers come from which. The perlguts and perlapi docs will help a lot with the perl end.

This kind of problem often occurs with libraries for complex data structures, but I've never tried hooking up to a whole different memory managment scheme. Good luck!

After Compline,
Zaxo


In reply to Re: interfacing with a boehm-gc library from XS by Zaxo
in thread interfacing with a boehm-gc library from XS by davidnicol

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.