Thanks -- yeah, marshalling all the calls into one thread is what I had planned to do all along, ironically. This was just proof-of-concept code, so I hadn't bothered to put the call marshalling in place yet. I got thrown for a loop by the exception until I realized that the one thing I hadn't ruled out last night was threading issues.

It was sort of a pain (for various reasons) to repro this in the actual embedded app, so I had created a "test app" that just embedded Perl the same way and called it directly. It didn't trap, which was frustrating. After I had my "threads epiphany", I added a couple lines of code to my test app to spawn the interpreter in another thread and hold it there until I signaled a shutdown. Then I called eval_pv() from the main thread and voila -- exception city. This was nice because the actual app was an injected DLL (long story) which made it VERY hard to debug the trap, whereas my test app was just a standalone executable, and it was a snap after the exception to step in and see where the interpreter was stashing the pointer to itself in thread-local storage. Oh well, live and learn.

Well, it's good to know that it's not thread safe. That will hopefully keep me from shooting myself in the foot like this in the future. I can't wait until ActiveState gets their distro up to 5.8 -- I would REALLY like better built-in threading behavior (I'm assuming that since ithreads is included, the core Perl modules have been made thread-safe -- is this a reasonable assumption?)

Thanks for the help and the pairs of eyes...

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.