Skip to content

Commit 75bedfb

Browse files
committed
avoid ext/XS-APItest/t/clone-with-stack.t crash
a fresh_perl() TODO test in this file does something like use XS::APItest; BEGIN { clone_with_stack(); } print "ok\n"; As a standalone program, this code gives errors under valgrind, and in ticket GH #21969 was causing "perl.exe has stopped working" on Windows 8. The clone_with_stack() XS function is fairly dodgy - it clones the whole interpreter including stacks (i.e. what fork() emulation on windows does), but then continues the RUNOPS loop to completion itself, using the cloned interpreter, rather than relying on the caller to finish the ops loop. This doesn't work very well under BEGIN (hence why it's a TODO test), but specifically, PL_curcop can be left pointing at an op which gets freed , but then is later accessed anyway. This commit resets PL_curcop to &PL_compiling to avoid crashes.
1 parent 72037da commit 75bedfb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ext/XS-APItest/APItest.xs

+5
Original file line numberDiff line numberDiff line change
@@ -4256,6 +4256,11 @@ CODE:
42564256
PL_scopestack_ix = oldscope;
42574257
}
42584258

4259+
/* the COP which PL_curcop points to is about to be freed, but might
4260+
* still be accessed when destructors, END() blocks etc are called.
4261+
* So point it somewhere safe.
4262+
*/
4263+
PL_curcop = &PL_compiling;
42594264
perl_destruct(interp_dup);
42604265
perl_free(interp_dup);
42614266

0 commit comments

Comments
 (0)