Skip to content

Commit

Permalink
C: revert 205fbbc Special-case io_close, move PerlIO_cleanup after sv…
Browse files Browse the repository at this point in the history
…_clean_objs

the cause for the io_close problem was that PerlIO_cleanup was called before sv_clean_objs.
global destruction -O3 looks better now
Fixes #302 CORE--op--utf8cache.t, CORE--op--lex_assign.t, CORE--io--openpid.t
  • Loading branch information
Reini Urban committed Feb 19, 2014
1 parent 2413c50 commit c186386
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 50 deletions.
6 changes: 3 additions & 3 deletions MANIFEST
Expand Up @@ -179,7 +179,7 @@ t/C-COMPILED/CORE--io--iprefix.t
t/C-COMPILED/CORE--io--layers==BADTEST-203.t
t/C-COMPILED/CORE--io--nargv.t
t/C-COMPILED/CORE--io--open.t
t/C-COMPILED/CORE--io--openpid==SIG-302.t
t/C-COMPILED/CORE--io--openpid.t
t/C-COMPILED/CORE--io--perlio.t
t/C-COMPILED/CORE--io--perlio_fail.t
t/C-COMPILED/CORE--io--perlio_leaks.t
Expand Down Expand Up @@ -267,7 +267,7 @@ t/C-COMPILED/CORE--op--lc_user.t
t/C-COMPILED/CORE--op--leaky-magic.t
t/C-COMPILED/CORE--op--length.t
t/C-COMPILED/CORE--op--lex.t
t/C-COMPILED/CORE--op--lex_assign==SIG-302.t
t/C-COMPILED/CORE--op--lex_assign.t
t/C-COMPILED/CORE--op--lfs.t
t/C-COMPILED/CORE--op--list.t
t/C-COMPILED/CORE--op--local.t
Expand Down Expand Up @@ -350,7 +350,7 @@ t/C-COMPILED/CORE--op--undef.t
t/C-COMPILED/CORE--op--universal==BADTEST-275.t
t/C-COMPILED/CORE--op--unshift.t
t/C-COMPILED/CORE--op--upgrade.t
t/C-COMPILED/CORE--op--utf8cache==SIG-302.t
t/C-COMPILED/CORE--op--utf8cache.t
t/C-COMPILED/CORE--op--utf8decode.t
t/C-COMPILED/CORE--op--utf8magic.t
t/C-COMPILED/CORE--op--utfhash.t
Expand Down
52 changes: 5 additions & 47 deletions lib/B/C.pm
Expand Up @@ -4530,11 +4530,6 @@ sub B::IO::save {
$svsect->debug($fullname, $io->flagspv) if $debug{flags};
$sym = savesym( $io, sprintf( "(IO*)&sv_list[%d]", $svsect->index ) );

if (!$PERL510 and $io->SvSTASH) { # issue 303: test 22
# still need to close filehandles and dirs
# and then protect del_XPVIO(SvANY(sv)) for fast_perl_destruct() before sv_clean_objs()
push @B::C::static_free, $sym;
}
if ($PERL510 and !$B::C::pv_copy_on_grow and $cur) {
$init->add(sprintf("SvPVX(sv_list[%d]) = $pvsym;", $svsect->index));
}
Expand Down Expand Up @@ -4908,9 +4903,6 @@ _EOT2
$init->add_initav(" Perl_die(aTHX_ \"panic: AV alloc failed\");");
}
}
if (!$PERL510) {
print "static void my_io_close( pTHX_ SV* const sv );\n";
}
if ( !$B::C::destruct ) {
print <<'__EOT';
int fast_perl_destruct( PerlInterpreter *my_perl );
Expand Down Expand Up @@ -4961,28 +4953,7 @@ my_share_hek( pTHX_ const char *str, I32 len, register U32 hash ) {
}
_EOT5
} else {
print <<'_EOT5a';
static void
my_io_close( pTHX_ SV* const sv ) {
if (IoIFP(sv) &&
IoIFP(sv) != PerlIO_stdin() &&
IoIFP(sv) != PerlIO_stdout() &&
IoIFP(sv) != PerlIO_stderr())
{
bool b = io_close((IO*)sv, FALSE);
}
if (IoDIRP(sv) && !(IoFLAGS(sv) & IOf_FAKE_DIRP))
PerlDir_close(IoDIRP(sv));
IoDIRP(sv) = (DIR*)NULL;
/* and now kill it off */
SvREFCNT(sv) = 0;
SvFLAGS(sv)= SVTYPEMASK;
}
_EOT5a

}

# -fno-destruct only >=5.8
if ( !$B::C::destruct ) {
print <<'_EOT6';
Expand Down Expand Up @@ -5178,37 +5149,24 @@ int fast_perl_destruct( PerlInterpreter *my_perl ) {
PerlIO_printf(Perl_debug_log, "sv_arena: 0x%p - 0x%p (%u)\n",
sva, sva+SvREFCNT(sva), SvREFCNT(sva));
}
}
}
#endif
PerlIO_destruct(aTHX);
#if defined(PERLIO_LAYERS)
PerlIO_cleanup(aTHX);
#endif
_EOT6

if (!$PERL510) {
for (0 .. $#B::C::static_free) {
my $s = $B::C::static_free[$_];
if ($s =~ /^\(IO\*\)&sv_list/) {
$s =~ s/^\(IO\*\)//;
print " my_io_close(aTHX_ $s);\n";
}
}
}

print <<'_EOT6a';
if (PL_sv_objcount) {
sv_clean_objs();
PL_sv_objcount = 0;
}
#if defined(PERLIO_LAYERS)
PerlIO_cleanup(aTHX);
#endif
PL_warnhook = NULL;
PL_diehook = NULL;
while (PL_exitlistlen-- > 0)
PL_exitlist[PL_exitlistlen].fn(aTHX_ PL_exitlist[PL_exitlistlen].ptr);
return 0;
}
_EOT6a
_EOT6

}
# special COW handling for 5.10 because of S_unshare_hek_or_pvn limitations
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c186386

Please sign in to comment.