On Tue, Mar 31, 2009 at 11:38:15AM -0700, David F. Skoll wrote:
> In Perl 5.10.0, it does not seem possible to create an interpreter,
> destroy it, and create another in the same process by following the
> perlembed instructions.  The attached test case works fine under
> Debian Etch (perl 5.8.8); running "./configure && make && ./embperl"
> prints "I'm very happy!" twice.  On lenny running Perl 5.10.0, the first
> one works, but then it prints:
> 
> panic: MUTEX_LOCK (22) [op.c:453] at script.pl line 1.
> BEGIN failed--compilation aborted at script.pl line 1.
> panic: MUTEX_LOCK (22) [op.c:453] at script.pl line 1.

This is also <http://bugs.debian.org/522099>, and as discussed there,
it seems to be a misunderstanding about the needed arguments for
PERL_SYS_INIT3(). The test case calls the macro (twice) with the
perl_parse() arguments, but apparently the "real" main() argc, argv and
env are the right ones.

If this is correct, maybe the attached documentation patch would help
to avoid similar confusion in the future?
-- 
Niko Tyni   [email protected]
>From 929aa4e752e0474630a4f957e012f131191a4054 Mon Sep 17 00:00:00 2001
From: Niko Tyni <[email protected]>
Date: Thu, 2 Apr 2009 20:54:10 +0300
Subject: [PATCH] Clarify PERL_SYS_INIT3() usage.

As seen in [perl #64326] and <http://bugs.debian.org/522099>, the
PERL_SYS_INIT3() documentation in perlembed.pod could be clearer about
the macro arguments.
---
 pod/perlembed.pod |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/pod/perlembed.pod b/pod/perlembed.pod
index 39364eb..3a16b98 100644
--- a/pod/perlembed.pod
+++ b/pod/perlembed.pod
@@ -202,6 +202,10 @@ of the C runtime environment necessary to run Perl interpreters; since
 PERL_SYS_INIT3() may change C<env>, it may be more appropriate to provide
 C<env> as an argument to perl_parse().
 
+Also notice that no matter what arguments you pass to perl_parse(),
+PERL_SYS_INIT3() must be invoked on the C main() argc, argv and env and
+only once.
+
 Now compile this program (I'll call it I<interp.c>) into an executable:
 
     % cc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
-- 
1.5.6.5

Reply via email to