http://www.perlmonks.org?node_id=1213555


in reply to XS/C, threads, and calling call_sv() with a code ref

If I understand you correctly, you have two different threads (the main perl interpreter, and a C++ thread activated by an interrupt) both accessing the same perl interpreter. This is a big no-no, and corruption is going to ensue.

The basic model of perl's current threading implementation, ithreads, is that each OS-level thread is given a separate perl interpreter, so that if they run in parallel, they can't stomp on each other's data. The perl internals just aren't designed for concurrent access - there are no internal locks protecting each SV and/or critical code sections.

Dave.