seen_eval regex field wasn't getting cloned
authorDave Mitchell <davem@fdisolutions.com>
Wed, 9 Jan 2008 23:57:36 +0000 (23:57 +0000)
committerDave Mitchell <davem@fdisolutions.com>
Wed, 9 Jan 2008 23:57:36 +0000 (23:57 +0000)
p4raw-id: //depot/perl@32933

regcomp.c
t/op/threads.t

index 03d1112..0c503e9 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -9458,7 +9458,6 @@ Perl_re_dup_guts(pTHX_ const REGEXP *sstr, REGEXP *dstr, CLONE_PARAMS *param)
 
     ret->mother_re      = NULL;
     ret->gofs = 0;
-    ret->seen_evals = 0;
 }
 #endif /* PERL_IN_XSUB_RE */
 
index 4679929..814b595 100644 (file)
@@ -16,7 +16,7 @@ BEGIN {
        exit 0;
      }
 
-     plan(12);
+     plan(13);
 }
 
 use strict;
@@ -169,4 +169,21 @@ threads->new(\&matchit, "Pie", qr/pie/i)->join();
 # tests in threads don't get counted, so
 curr_test(curr_test() + 2);
 
+
+# the seen_evals field of a regexp was getting zeroed on clone, so
+# within a thread it didn't  know that a regex object contrained a 'safe'
+# re_eval expression, so it later died with 'Eval-group not allowed' when
+# you tried to interpolate the object
+
+sub safe_re {
+    my $re = qr/(?{1})/;       # this is literal, so safe
+    eval { "a" =~ /$re$re/ };  # interpolating safe values, so safe
+    ok($@ eq "", 'clone seen-evals');
+}
+threads->new(\&safe_re)->join();
+
+# tests in threads don't get counted, so
+curr_test(curr_test() + 1);
+
+
 # EOF