Skip to content

Commit

Permalink
Revert "postpone perl_parse() exit(0) bugfix"
Browse files Browse the repository at this point in the history
This reverts commit 857320c,
re-instating the [perl Perl#2754] fix, which was reverted in late
2017 to allow Module::Install based distributions to update or
re-work per [perl #132577].

# Conflicts:
#	t/op/blocks.t
  • Loading branch information
tonycoz committed Jul 9, 2019
1 parent 256dda5 commit 2773b4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
27 changes: 8 additions & 19 deletions perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1624,16 +1624,13 @@ For historical reasons, the non-zero return value also attempts to
be a suitable value to pass to the C library function C<exit> (or to
return from C<main>), to serve as an exit code indicating the nature
of the way initialisation terminated. However, this isn't portable,
due to differing exit code conventions. A historical bug is preserved
for the time being: if the Perl built-in C<exit> is called during this
function's execution, with a type of exit entailing a zero exit code
under the host operating system's conventions, then this function
returns zero rather than a non-zero value. This bug, [perl #2754],
leads to C<perl_run> being called (and therefore C<INIT> blocks and the
main program running) despite a call to C<exit>. It has been preserved
because a popular module-installing module has come to rely on it and
needs time to be fixed. This issue is [perl #132577], and the original
bug is due to be fixed in Perl 5.30.
due to differing exit code conventions. An attempt is made to return
an exit code of the type required by the host operating system, but
because it is constrained to be non-zero, it is not necessarily possible
to indicate every type of exit. It is only reliable on Unix, where a
zero exit code can be augmented with a set bit that will be ignored.
In any case, this function is not the correct place to acquire an exit
code: one should get that from L</perl_destruct>.
=cut
*/
Expand Down Expand Up @@ -1842,15 +1839,7 @@ perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env)
call_list(oldscope, PL_checkav);
}
ret = STATUS_EXIT;
if (ret == 0) {
/*
* At this point we should do
* ret = 0x100;
* to avoid [perl #2754], but that bugfix has been postponed
* because of the Module::Install breakage it causes
* [perl #132577].
*/
}
if (ret == 0) ret = 0x100;
break;
case 3:
PerlIO_printf(Perl_error_log, "panic: top_env\n");
Expand Down
12 changes: 6 additions & 6 deletions t/op/blocks.t
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,23 @@ SKIP: {
skip "VMS doesn't have the perl #2754 bug", 3 if $^O eq 'VMS';
fresh_perl_is(
"$testblocks BEGIN { exit 0; }",
"begin\nunitcheck\ncheck\ninit\nend",
"begin\nunitcheck\ncheck\nend",
{},
"BEGIN{exit 0} doesn't exit yet"
"BEGIN{exit 0} should exit"
);

fresh_perl_is(
"$testblocks UNITCHECK { exit 0; }",
"begin\nunitcheck\ncheck\ninit\nmain\nend",
"begin\nunitcheck\ncheck\nend",
{},
"UNITCHECK{exit 0} doesn't exit yet"
"UNITCHECK{exit 0} should exit"
);

fresh_perl_is(
"$testblocks CHECK { exit 0; }",
"begin\nunitcheck\ncheck\ninit\nmain\nend",
"begin\nunitcheck\ncheck\nend",
{},
"CHECK{exit 0} doesn't exit yet"
"CHECK{exit 0} should exit"
);
}

Expand Down

0 comments on commit 2773b4f

Please sign in to comment.