summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2007-10-10 15:03:16 +0000
committerDave Mitchell <davem@fdisolutions.com>2007-10-10 15:03:16 +0000
commit401667e9af6ec282136e4e49614eb18614c5654b (patch)
tree3ebb10d18d00ed4a592ea9e627e043795c4cd72d /op.c
parent5108dc18037af131227ae095719eaab3a8fd54cb (diff)
downloadperl-401667e9af6ec282136e4e49614eb18614c5654b.tar.gz
newCONTSUB() wasn't thread-safe ([perl #45053])
p4raw-id: //depot/perl@32091
Diffstat (limited to 'op.c')
-rw-r--r--op.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/op.c b/op.c
index a74743ed5b..15510b27c4 100644
--- a/op.c
+++ b/op.c
@@ -5696,6 +5696,13 @@ Perl_newCONSTSUB(pTHX_ HV *stash, const char *name, SV *sv)
ENTER;
+ if (IN_PERL_RUNTIME) {
+ /* at runtime, it's not safe to manipulate PL_curcop: it may be
+ * an op shared between threads. Use a non-shared COP for our
+ * dirty work */
+ SAVEVPTR(PL_curcop);
+ PL_curcop = &PL_compiling;
+ }
SAVECOPLINE(PL_curcop);
CopLINE_set(PL_curcop, PL_parser ? PL_parser->copline : NOLINE);