dup saved_curcop in PL_parser
authorDavid Mitchell <davem@iabyn.com>
Sun, 26 Jul 2009 01:19:20 +0000 (02:19 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 26 Jul 2009 12:29:36 +0000 (13:29 +0100)
Commit 7c4baf47da introduced the saved_curcop field of PL_parser,
but omitted to copy the entry during interpreter cloning.
This may fix bugs [RT #58468], [RT #59498]

(cherry picked from commit f0c5aa00eeb992584d6996af147c4c51fe7a6540)

sv.c

diff --git a/sv.c b/sv.c
index cde1f00..a251b21 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -10169,6 +10169,10 @@ Perl_parser_dup(pTHX_ const yy_parser *proto, CLONE_PARAMS* param)
     Copy(proto->nexttype, parser->nexttype, 5, I32);
     parser->nexttoke   = proto->nexttoke;
 #endif
+
+    /* XXX should clone saved_curcop here, but we aren't passed
+     * proto_perl; so do it in perl_clone_using instead */
+
     return parser;
 }
 
@@ -11839,6 +11843,13 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
     PL_parser          = proto_perl->Iparser ?
                            parser_dup(proto_perl->Iparser, param): NULL;
 
+    /* XXX this only works if the saved cop has already been cloned */
+    if (proto_perl->Iparser) {
+       PL_parser->saved_curcop = (COP*)any_dup(
+                                   proto_perl->Iparser->saved_curcop,
+                                   proto_perl);
+    }
+
     PL_subline         = proto_perl->Isubline;
     PL_subname         = sv_dup_inc(proto_perl->Isubname, param);