On Wed, 13 Nov 2002 02:36:13 -0500 (EST), Zac Hansen
<[EMAIL PROTECTED]> wrote:

>I'm getting segfaults in perl_construct and perl_parse.  It seems to be 
>"random" which one it crashes in. (Note: when I went back and tried to get 
>a core dump for perl_parse, I couldn't get it to get past perl_construct) 
>I'm running multithreaded 5.8 built with (-O2 -g) on RedHat 6.2 with egcs 
>2.91.66.
>
>
>My program specifies PERL_NO_GET_CONTEXT and frequently passes perl 
>interpreters between threads.  In this case, it's calling perl_construct 
>in a different thread than perl_alloc.  Is this okay?  (I can't find 
>anything that says I can't..)  

Make sure you always save, set and restore the Perl context (using
Perl_get_context() and Perl_set_context()).  The context is stored in
thread local storage so that functions that don't pass the context
explicitly can still get at it.

    PerlInterpreter *old_perl = Perl_get_context();
    Perl_set_context(my_perl);

    // work with my_perl

    Perl_set_context(old_perl);

And make sure you call Perl_set_context() after calling perl_alloc(), but
before calling perl_construct().

Of course you also should make sure that each interpreter is only active
inside a single thread at any point in time.

Cheers,
-Jan

Reply via email to