Hi there!

Is it possible to generate a PerlInterpreter instance, delete it and then build a new PerlInterpreter instance if you didn't compile your perl with -DMULTIPLICITY?

We've written a segfaulting sample prog:

extern "C" { #include <EXTERN.h> #include <perl.h> #include <XSUB.h> } #include <iostream> PerlInterpreter *perlInt; void start() { perlInt = perl_alloc(); perl_construct(perlInt); char *embedding[] = { "", "-w", "-e", "use diagnostics;" }; perl_parse(perlInt, NULL, 4, embedding, NULL); perl_run(perlInt); PL_perl_destruct_level = 1; cout << "destructing..." << flush; perl_destruct(perlInt); cout << "done" << endl; perl_free(perlInt); } int main() { start(); start(); return 0; }

The output is:

cordelia:~/stuff/xpertmud/xpertmud 201> ./perl_problem
destructing...done
destructing...Segmentation fault

backtrace:

Starting program: 
/home/tmp/klimek/shadow/xpertmud/xpertmud/xpertmud/./perl_problem
destructing...done
destructing...
Program received signal SIGSEGV, Segmentation fault.
0x4015ae8e in free () from /lib/libc.so.6
(gdb) back
#0  0x4015ae8e in free () from /lib/libc.so.6
#1  0x4015ae19 in free () from /lib/libc.so.6
#2  0x0805a523 in perl_destruct () at eval.c:41
#3  0x08059922 in start () at perl_problem.cc:21
#4  0x08059964 in main () at perl_problem.cc:29
#5  0x400f7237 in __libc_start_main () from /lib/libc.so.6

The question: Is this some general problem or did we do something wrong?

Thanks for any help,
        Manuel

In reply to Perl Embed repeated allocation with diagnostics by Anonymous Monk

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.