I managed to reproduce the problem in a standalone testcase.

It seems that the different coderef values from Perl and XS are a red herring. I guess dereferencing a coderef in Perl has some indirection magic that I don't understand, because I get different values in the following test script, but that doesn't stop it from working?

#! perl -slw use strict; use Inline 'NoClean', 'FORCE', 'INFO' ; use Inline Config => WARNINGS => 4; use Inline 'C' => 'DATA', NAME =>'test'; sub recorder{ print "record: @_"; } sub player{ print "player: @_"; } printf "r:%x p:%x\n", \&recorder, \&player; setCallbacks( \&recorder, \&player ); record( 'test' ); #record( 'test' ); #play( 'test' ); __DATA__ __C__ SV *g_rec = 0, *g_play = 0; int setCallbacks( SV *rec, SV *play ) { printf( "r:%x p:%x\n", rec, play ); g_rec = rec; SvREFCNT_inc( g_rec ); g_play = play; SvREFCNT_inc( g_play ); return 0; } int record( SV *m ) { call_sv( g_rec, G_VOID ); return 0; } int play( SV *m ) { call_sv( g_play, G_VOID ); return 0; }

As is, with the second call to record() and that to play() commented out, the program runs fine

P:\test>test r:226004 p:2260b8 r:19499e4 p:2252a8 record: test

Different addresses(?), but it works. Remove either comment and it panics.

P:\test>test r:226004 p:2260b8 r:19499e4 p:2252a8 record: test panic: memory wrap at P:\test\test.pl line 16.

I assume that it is something to do with my (lack of) handling of the stack(?), but I've tried various combinations of the Inline_* macros without success.

Cluebats gratefully receieved.


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^2: panic: memory wrap by BrowserUk
in thread panic: memory wrap 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.