summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-06-08 20:29:54 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-06-08 21:59:08 -0700
commit4a808ed163df1057031bc6d085300fe1ef6f57d2 (patch)
treedb9b7cfea1f1c07540bb3aae29ce93418812f738 /ext
parentd5db65c043a15d90a511bcd6b528dd7925d0ffa0 (diff)
downloadperl-4a808ed163df1057031bc6d085300fe1ef6f57d2.tar.gz
[perl #111610] Trouble with XS-APItest/t/clone-with-stack.t
I ran into a bit of a problem when building perl-5.16.0. 'make test' showed a segfault in ext/XS-APItest/t/clone-with-stack.t. It seems to be caused by accessing already freed memory, it segfaults because I have MALLOC_PERTUBE_ set, thus glibc fills freed memory with some value. Digging deeper, it seems like perl_clone() does not fix the cx's blk_oldcop element when doing context cloning, thus blk_oldcop still points to PL_compiling in the old interp--the calling scope for the BEGIN block being the compilation of the code surrounding it--and the POPBLOCK done in leavesub will copy the data from the old interp to PL_curcop. After fixing this, it still crashed because interp_dup->Iop was zero after the runops_standard() call (which is probably correct as the end of the BEGIN block was reached). So I also added an if statement that checks the pointer.
Diffstat (limited to 'ext')
-rw-r--r--ext/XS-APItest/APItest.xs3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index 2c0ee61493..69b706613b 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -3084,7 +3084,8 @@ CODE:
PERL_SET_CONTEXT(interp_dup);
/* continue after 'clone_with_stack' */
- interp_dup->Iop = interp_dup->Iop->op_next;
+ if (interp_dup->Iop)
+ interp_dup->Iop = interp_dup->Iop->op_next;
/* run with new perl */
Perl_runops_standard(interp_dup);