summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-01 14:31:37 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-01 14:31:37 +0000
commita24d89c9b4c1e58840711d560a34763a7ca91051 (patch)
treed13f807afb7745e725f87a7d9fb37f52313ab56e /pp_ctl.c
parent9b2c10f1c598e1e6a0db9d0b301c9559b079b129 (diff)
downloadperl-a24d89c9b4c1e58840711d560a34763a7ca91051.tar.gz
Propagate cop_hints inside string evals. For the unthreaded case this
is easy. For the threaded case it's not, because the current OP may be shared with another thread, so solve this by copying the hints chain. p4raw-id: //depot/perl@27659
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 72caef3d67..1fcbbacf8e 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3476,6 +3476,29 @@ PP(pp_entereval)
PL_compiling.cop_io = newSVsv(PL_curcop->cop_io);
SAVEFREESV(PL_compiling.cop_io);
}
+ if (PL_compiling.cop_hints) {
+ PL_compiling.cop_hints->refcounted_he_refcnt--;
+ }
+ PL_compiling.cop_hints = PL_curcop->cop_hints;
+ if (PL_compiling.cop_hints) {
+#ifdef USE_ITHREADS
+ /* PL_curcop could be pointing to an optree owned by another /.*parent/
+ thread. We can't manipulate the reference count of the refcounted he
+ there (race condition) so we have to do something less than
+ pleasant to keep it read only. The simplest solution seems to be to
+ copy their chain. We might want to cache this.
+ Alternatively we could add a flag to the refcounted he *we* point to
+ here saying "I don't own a reference count on the thing I point to",
+ and arrange for Perl_refcounted_he_free() to spot that. If so, we'd
+ still need to copy the topmost refcounted he so that we could change
+ its flag. So still not trivial. (Flag bits could be hung from the
+ shared HEK) */
+ PL_compiling.cop_hints
+ = Perl_refcounted_he_copy(aTHX_ PL_compiling.cop_hints);
+#else
+ PL_compiling.cop_hints->refcounted_he_refcnt++;
+#endif
+ }
/* special case: an eval '' executed within the DB package gets lexically
* placed in the first non-DB CV rather than the current CV - this
* allows the debugger to execute code, find lexicals etc, in the