First. Many thanks for having continued to pursue this. Above and beyond.

but afaict there is something not right with GD-2.30, either

I was reaching a similar conclusion myself--and it doesn't appear to be limited to 2.30 (which I have yet have pass it's own testsuite so I haven't installed it).

Having reverted to 5.8.6, I find that GD 2.28 also produces this error there, though I have to exercise it harder, (loop more times), before it occurs. If I hadn't seen the error several times with other, non-GD, non-threads code since I upgraded to 5.8.7, I would've been more inclined to point the finger at GD despite the authorship.

I am a neophyte as far as XS is concerned. However, I think I may have cracked it?

GD::Image gdnewFromGdData(packname="GD::Image", imageData) char * packname SV * imageData PROTOTYPE: $$ PREINIT: char* data; STRLEN len; CODE: data = SvPV(imageData,len); RETVAL = (GD__Image) gdImageCreateFromGdPtr(len,(void*) data); // safefree(data); /// HERE! OUTPUT: RETVAL

See HERE! above. I made this change and (on very first blush), it appears to fix the problem with my OP code and the original from which it is derived.

If I understand the above correctly, data is just a pointer to a part of an SV that I pass in, so the library should not be freeing it? It should leave it intact until the SV get gc'd in the normal way? Does that make sense to you?

If correct, then the newFromGD2Data() call is similarly affected, but not any of the others (png/jpeg/WBMP) as they do not free the data passed in.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^10: Segfault on second (identical) call to a sub by BrowserUk
in thread Segfault on second (identical) call to a sub by BrowserUk

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.