<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://community.activestate.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>ActiveState Community Site - Free to wrong pool with multiple interpreters - Comments</title>
 <link>http://community.activestate.com/forum-topic/free-wrong-pool-multiple-interpreters</link>
 <description>Comments for &quot;Free to wrong pool with multiple interpreters&quot;</description>
 <language>en</language>
<item>
 <title>Free to wrong pool with multiple interpreters</title>
 <link>http://community.activestate.com/forum-topic/free-wrong-pool-multiple-interpreters</link>
 <description>&lt;p&gt;I&#039;m trying to use multiple perl interpreters within a single thread (embedding perl in C). I&#039;ve tried to follow the instructions in the perlembed document (under the section Maintaining multiple interpreter instances), but I get a crash with the message &quot;Free to wrong pool XX not YY&quot;. I&#039;m trying to figure out if I&#039;m doing something wrong here.&lt;/p&gt;
&lt;p&gt;My C program and perl scripts are quite simple:&lt;/p&gt;
&lt;pre class=&quot;geshifilter&quot;&gt;#include 
#include 

void main()
{
	PerlInterpreter *my_perl;
	PerlInterpreter *my_perl2;
	static char *embedding[] = { &quot;&quot;, &quot;-e&quot;, &quot;0&quot; };
	static char *embedding2[] = { &quot;&quot;, &quot;-e&quot;, &quot;0&quot; };

	my_perl = perl_alloc();
	my_perl2 = perl_alloc();
	PERL_SET_CONTEXT(my_perl);
	PL_perl_destruct_level = 1;
	perl_construct(my_perl);
	PERL_SET_CONTEXT(my_perl2);
	PL_perl_destruct_level = 1;
	perl_construct(my_perl2);
		

	PERL_SET_CONTEXT(my_perl);
	perl_parse(my_perl, NULL, 3, embedding, (char **)NULL);
	PERL_SET_CONTEXT(my_perl2);
	perl_parse(my_perl2, NULL, 3, embedding2, (char **)NULL);
	
	PERL_SET_CONTEXT(my_perl);
	perl_run(my_perl);
	PERL_SET_CONTEXT(my_perl2);
	perl_run(my_perl2);

	PERL_SET_CONTEXT(my_perl);
	eval_pv(&quot;do &#039;C:\\temp\\test.pl&#039;&quot;, TRUE);
	printf(&quot;a = %d\n&quot;, SvIV(get_sv(&quot;a&quot;, FALSE)));
	
	eval_pv(&quot;do &#039;C:\\temp\\test.pl&#039;&quot;, TRUE);
	printf(&quot;a = %d\n&quot;, SvIV(get_sv(&quot;a&quot;, FALSE)));

	PERL_SET_CONTEXT(my_perl2);
	eval_pv(&quot;do &#039;C:\\temp\\test.pl&#039;&quot;, TRUE); //Crash here
	printf(&quot;b = %d\n&quot;, SvIV(get_sv(&quot;b&quot;, FALSE)));

	PERL_SET_CONTEXT(my_perl2);
	PL_perl_destruct_level = 1;
	perl_destruct(my_perl2);
	PERL_SET_CONTEXT(my_perl);
	PL_perl_destruct_level = 1;
	perl_destruct(my_perl);
	

	PERL_SET_CONTEXT(my_perl);
	perl_free(my_perl);
	PERL_SET_CONTEXT(my_perl2);
	perl_free(my_perl2);

}&lt;/pre&gt;&lt;p&gt;
test.pl:&lt;/p&gt;
&lt;pre class=&quot;geshifilter&quot;&gt;$a += 1;&lt;/pre&gt;&lt;p&gt;
Is there something I&#039;m doing wrong/not understanding, or have I enountered a bug?&lt;/p&gt;
&lt;p&gt;Thanks for the help.&lt;/p&gt;
</description>
 <comments>http://community.activestate.com/forum-topic/free-wrong-pool-multiple-interpreters#comments</comments>
 <category domain="http://community.activestate.com/forums/activeperl-support-0">ActivePerl Support</category>
 <category domain="http://community.activestate.com/os/windows-vista">Windows Vista</category>
 <pubDate>Wed, 24 Oct 2007 09:14:08 -0700</pubDate>
 <dc:creator>koekje</dc:creator>
 <guid isPermaLink="false">1547 at http://community.activestate.com</guid>
</item>
</channel>
</rss>
