From 197bb3f4412b47e2f91dcf54c64d12d9fd05967b Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Mon, 29 Aug 2022 13:25:56 +0200 Subject: [PATCH] Revert "postpone perl_parse() exit(0) bugfix" This reverts commit 857320cbf85e762add18885ae8a197b5e0c21b69. There were a lot of conflicts due to whitespace changes in the intervening time. I manually reviewed the differences and merged them. --- perl.c | 26 +++++++++++--------------- t/op/blocks.t | 8 ++++---- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/perl.c b/perl.c index c63e263..aec3f24 100644 --- a/perl.c +++ b/perl.c @@ -1733,16 +1733,13 @@ For historical reasons, the non-zero return value also attempts to be a suitable value to pass to the C library function C (or to return from C
), 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 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 being called (and therefore C blocks and the -main program running) despite a call to C. 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. =cut */ @@ -1935,12 +1932,11 @@ perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env) 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]. + * We do this here to avoid [perl #2754]. + * Note this may cause trouble with Module::Install. + * See: [perl #132577]. */ + ret = 0x100; } break; case 3: diff --git a/t/op/blocks.t b/t/op/blocks.t index 102f188..4b3b7f1 100644 --- a/t/op/blocks.t +++ b/t/op/blocks.t @@ -147,7 +147,6 @@ fresh_perl_is('END { print "ok\n" } INIT { bless {} and exit }', "ok\n", {}, 'null PL_curcop in newGP'); # [perl #2754] exit(0) didn't exit from inside a UNITCHECK or CHECK block - my $testblocks = join(" ", "BEGIN { \$| = 1; }", @@ -167,21 +166,21 @@ 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" ); fresh_perl_is( "$testblocks UNITCHECK { exit 0; }", - "begin\nunitcheck\ncheck\ninit\nmain\nend", + "begin\nunitcheck\ncheck\nend", {}, "UNITCHECK{exit 0} doesn't exit yet" ); fresh_perl_is( "$testblocks CHECK { exit 0; }", - "begin\nunitcheck\ncheck\ninit\nmain\nend", + "begin\nunitcheck\ncheck\nend", {}, "CHECK{exit 0} doesn't exit yet" ); @@ -258,6 +257,7 @@ fresh_perl_like( "INIT{die} should exit" ); + TODO: { local $TODO = 'RT #2917: INIT{} in eval is wrongly considered too late'; fresh_perl_is('eval "INIT { print qq(in init); };";', 'in init', {}, 'RT #2917: No constraint on how late INIT blocks can run'); -- 1.8.3.1