Bug#486069: perl: embedding perl hangs on hppa without PERL_SYS_INIT3() since 5.10.0

Julien ÉLIE julien at trigofacile.com
Fri Jun 27 22:34:35 UTC 2008


Hi Russ,

> Something to sneak in for the next stable release.  Looks like we just
> need to call PERL_SYS_INIT3() as documented in the perlembed man page when
> initializing Perl.

According to

    http://perldoc.perl.org/perlembed.html

there is also PERL_SYS_TERM() to add after having closed the Perl interpreter.

As for PERL_SYS_INIT3(), I do not know whether it is really necessary for us
and if we also need to use it during the execution of the code.
There are perl_call_argv() calls for instance with arguments.


> | Packages that are probably broken on hppa because they don't call
> | PERL_SYS_INIT3() so their embedded perl interpreter hangs in perl_parse():

Only perl_parse() then?


I can apply something like that.  Please tell me if it looks fine.


Index: lib/perl.c
===================================================================
--- lib/perl.c  (révision 7873)
+++ lib/perl.c  (copie de travail)
@@ -99,21 +99,8 @@
     }
 }

-static void PerlParse (void)
-{
-    const char *argv[] = { "innd",
-                           "-e", "sub _load_ { do $_[0] }",
-                           "-e", "sub _eval_ { eval $_[0] }",
-                           NULL } ;

-    /* We can't call 'eval' and 'do' directly for some reason, so we define
-       some wrapper functions to give us access. */
-
-    perl_parse (PerlCode,xs_init,5,(char **)argv,NULL) ;
-}

-
-
 /*
 ** Loads a setup Perl module. startupfile is the name of the file loaded
 ** one-time at startup. filterfile is the file containing the filter
@@ -124,9 +111,20 @@
 void PERLsetup (char *startupfile, char *filterfile, const char *function)
 {
     if (PerlCode == NULL) {
+        int argc = 5;
+        const char *argv[] = { "innd",
+                         "-e", "sub _load_ { do $_[0] }",
+                         "-e", "sub _eval_ { eval $_[0] }",
+                         NULL };
+        char *env[]  = { NULL };
+
+        PERL_SYS_INIT3(&argc, &argv, &env);
         PerlCode = perl_alloc();
         perl_construct(PerlCode);
-        PerlParse () ;
+
+        /* We cannot call 'eval' and 'do' directly for some reason, so we define
+         * some wrapper functions to give us access. */
+        perl_parse(PerlCode, xs_init, argc, (char **)argv, env) ;
     }


I do not know whether PERL_SYS_INIT3() should be called before perl_alloc() or not
so I put the PerlParse function in PERLsetup().

Anyway, INN seems to work fine with this patch (innd and nnrpd Perl filters work).

-- 
Julien ÉLIE

« -- Heureusement, nous aurons bientôt le TGV !
  -- C'est quoi le tégévé ?
  -- C'est le Transport Gaulois Véloce » (Astérix) 



More information about the inn-workers mailing list