I may have found the answer. My Perl distro (ActiveState, which is a 5.6.1 Win32 port), is compiled without either USE_THREADS or USE_ITHREADS. I'm not sure why that should matter (aren't these just for INTERNAL Perl threading?) but I've discovered that if I call eval_pv() from a __different O/S thread__ than the one I initialized the interpreter in, it traps. If I call from the same thread, it doesn't. I debugged it a little and found some calls to various TLS functions, so it appears that the simple expedient of storing my_perl in a global variable wasn't enough. Behind the scenes a pointer to it was getting stashed in thread-local storage, so that when I switched context over to my other thread, the pointer was null (different TLS instance) and we trapped as soon as we tried to use the interpreter pointer. VERY non-intuitive... As a C++ coder, I assume that if I dereference a global variable, it will have the same value over all functions in the module (assuming it isn't changed locally). However, this doesn't seem to match the actual behavior I'm seeing...

In reply to Re: Re: Unorthodox Embedding/XS madness! by Ouroborous
in thread Unorthodox Embedding/XS madness! by Ouroborous

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.