I needed libalgorithm-permute-perl as dependency of one of my scripts.

The perlapi changed between 5.22 and 5.24, so just recompilation won't do the trick.

I've tried to fix it (PUSHBLOCK was replaced by new cx_pushblock, etc ...), but as it is first times I've done something with the xs / perlguts / perl internals, my fix was not perfect. The code compiles and installs cleanly, some of my scripts using Algorithm::Permute run properly, but some of them fail with segfault or some "panic: pp_iter, type=0" message.

Well, in worst case anybody can use my patch until someone else fixes this properly... or use this patch as base of a proper patch.

Martin Petricek
Author: Martin Petricek <m...@pdfedit.cz>
Date:   Sun Nov 6 22:21:11 2016 +0100

    Partial fix for perlapi 5.24

diff --git Permute.xs Permute.xs
index 4b47499..116a92c 100644
--- Permute.xs
+++ Permute.xs
@@ -472,6 +472,8 @@ SV* array_sv;
     struct afp_cache *c;
     I32 hasargs = 0;
     SV** newsp;
+    OP *retop     = PL_op->op_next;
+    I32 old_ss_ix = PL_savestack_ix;
   PPCODE:
 {
     if (!SvROK(callback_sv) || SvTYPE(SvRV(callback_sv)) != SVt_PVCV)
@@ -533,8 +535,8 @@ SV* array_sv;
     SAVETMPS;
     SAVESPTR(PL_op);
 
-    PUSHBLOCK(cx, CXt_NULL, SP);  /* make a pseudo block */
-    PUSHSUB(cx);
+    cx = cx_pushblock(CXt_NULL, gimme, MARK, old_ss_ix);  /* make a pseudo 
block */
+    cx_pushsub(cx, callback, retop, hasargs);
 
     old_catch = CATCH_GET;
     CATCH_SET(TRUE);
@@ -543,6 +545,6 @@ SV* array_sv;
     permute_engine(c->array, AvARRAY(c->array), 0, c->len, 
         c->tmparea, CvSTART(callback));
     
-    POPBLOCK(cx,PL_curpm);
+    cx_popblock(cx);
     CATCH_SET(old_catch);
 }

Reply via email to