Skip to content

Commit

Permalink
S_process_special_blocks() should use a new stack for BEGIN blocks.
Browse files Browse the repository at this point in the history
This avoids the stack moving underneath anything that directly or indirectly
calls Perl_load_module().

[Committer’s note:

 This fixes bug #119993.

 Furthermore, under STRESS_REALLOC, t/io/layers.t was crashing like this:

 $ ./perl -Ilib -e ' open(UTF, "<:raw:encoding(utf8)", 'tmp75851B') or die $!; ref #blahblahblahblahblahblahblahblahblah'
 Segmentation fault: 11

 (The comment seems to be necessary to make it crash.)

 It was happening because open() was causing a module to be loaded
 while the arguments to open() were still on the stack.
]
  • Loading branch information
nwc10 authored and Father Chrysostomos committed Nov 23, 2013
1 parent ea35f80 commit ebdc880
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -7957,8 +7957,10 @@ S_process_special_blocks(pTHX_ I32 floor, const char *const fullname,
if (*name == 'B') {
if (strEQ(name, "BEGIN")) {
const I32 oldscope = PL_scopestack_ix;
dSP;
if (floor) LEAVE_SCOPE(floor);
ENTER;
PUSHSTACKi(PERLSI_REQUIRE);
SAVECOPFILE(&PL_compiling);
SAVECOPLINE(&PL_compiling);
SAVEVPTR(PL_curcop);
Expand All @@ -7968,6 +7970,7 @@ S_process_special_blocks(pTHX_ I32 floor, const char *const fullname,
GvCV_set(gv,0); /* cv has been hijacked */
call_list(oldscope, PL_beginav);

POPSTACK;
LEAVE;
}
else
Expand Down

0 comments on commit ebdc880

Please sign in to comment.