Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, monks!

I have such XS code:
#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" PerlInterpreter* my_perl; char* perl_lib_path = "/some/path/test.pm"; MODULE = TestModule PACKAGE = TestModule void upd_init(SV* perl_object) CODE: char *argv[] = {"", perl_lib_path}; my_perl = perl_alloc(); perl_construct( my_perl ); perl_parse(my_perl, NULL, 2, argv, (char **)NULL); perl_run(my_perl); dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(perl_object); PUTBACK; call_pv("test::init", G_DISCARD); FREETMPS; LEAVE; void upd_deinit() CODE: perl_destruct(my_perl); perl_free(my_perl);
And when I run perl-script as following:
#!/usr/bin/env perl use strict; use PerlTestModule; my $ptm = new PerlTestModule(); TestLogger::upd_init($ptm);
I get error: "panic: free from wrong pool."

Does anybody know why?

Replies are listed 'Best First'.
Re: panic: free from wrong pool.
by cdarke (Prior) on Mar 16, 2009 at 16:24 UTC
    You might get some help from here.

    Google on "panic: free from wrong pool" gives hits which may be worth a look.
Re: panic: free from wrong pool.
by chromatic (Archbishop) on Mar 17, 2009 at 09:23 UTC

    Are you trying to embed a Perl interpreter within a Perl interpreter? I thought (but can't confirm at the moment) that you need a Perl compiled with -DMULTIPLICITY or something special to make this work.

    If that's not what you're trying to do, then perhaps you can explain your goal more clearly.

      Yes, I've read manuals about XS & callbakcs and understood.. It was very very bad solution.