Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 223e183

Browse files
author
Reini Urban
committed
signatures: fix cx_dup #163
duplicate the cx->safearray with signatures correctly. with sigs the safearray is just a MARK ptr onto the SV** stack, not a AV*. duplicate both safearray and argarray with sigs to the new stack locations. We don't need to dup more cv fields, CvSIGOP stays as is. Closes #163
1 parent d543038 commit 223e183

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

cop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ struct block_sub {
555555
CV * cv;
556556
/* Above here is the same for sub and format. */
557557
I32 olddepth;
558-
AV *savearray;
559-
SV ** argarray; /* for signatures only */
558+
AV * savearray; /* with signatures just a SV** on the stack */
559+
SV ** argarray; /* for signatures only, the MARK */
560560
};
561561

562562

cpan/Test-Simple/t/subtest/fork.t

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ else {
2020
}
2121

2222
subtest 'fork within subtest' => sub {
23-
plan tests => 2;
24-
25-
TODO: {
26-
local $TODO = "random fork problem with MSVC"
27-
if ($^O eq 'MSWin32' and $Config{cc} eq 'cl');
23+
plan tests => 2;
2824

2925
my $pipe = IO::Pipe->new;
3026
my $pid = fork;
@@ -51,6 +47,5 @@ subtest 'fork within subtest' => sub {
5147
diag 'Child Done';
5248
exit 0;
5349
}
54-
}
5550
};
5651

sv.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14075,14 +14075,22 @@ Perl_cx_dup(pTHX_ PERL_CONTEXT *cxs, I32 ix, I32 max, CLONE_PARAMS* param)
1407514075
ncx->blk_oldcop = (COP*)any_dup(ncx->blk_oldcop, param->proto_perl);
1407614076
switch (CxTYPE(ncx)) {
1407714077
case CXt_SUB:
14078-
ncx->blk_sub.cv = cv_dup_inc(ncx->blk_sub.cv, param);
14079-
if(CxHASARGS(ncx)){
14080-
ncx->blk_sub.savearray = av_dup_inc(ncx->blk_sub.savearray,param);
14081-
} else {
14082-
ncx->blk_sub.savearray = NULL;
14083-
}
14078+
ncx->blk_sub.cv = cv_dup_inc(ncx->blk_sub.cv, param);
14079+
if (CvHASSIG(ncx->blk_sub.cv)) { /* SP ptrs */
14080+
PerlInterpreter *proto_perl = param->proto_perl;
14081+
int oldsave = (SV**)ncx->blk_sub.savearray - proto_perl->Istack_base;
14082+
int oldarg = ncx->blk_sub.argarray - proto_perl->Istack_base;
14083+
ncx->blk_sub.savearray = (AV*)(PL_stack_base + oldsave);
14084+
ncx->blk_sub.argarray = PL_stack_base + oldarg;
14085+
} else {
14086+
if (CxHASARGS(ncx)) {
14087+
ncx->blk_sub.savearray = av_dup_inc(ncx->blk_sub.savearray, param);
14088+
} else {
14089+
ncx->blk_sub.savearray = NULL;
14090+
}
14091+
}
1408414092
ncx->blk_sub.prevcomppad = (PAD*)ptr_table_fetch(PL_ptr_table,
14085-
ncx->blk_sub.prevcomppad);
14093+
ncx->blk_sub.prevcomppad);
1408614094
break;
1408714095
case CXt_EVAL:
1408814096
ncx->blk_eval.old_namesv = sv_dup_inc(ncx->blk_eval.old_namesv,

0 commit comments

Comments
 (0)