-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] can't exit 0 from CHECK{} #1537
Comments
From tchrist@chthon.perl.comFrom a CHECK{}, you cannot exit(0). You may exit !0, but not 0. #BEGIN { warn "testing exit from BEGIN"; exit } #INIT { warn "testing exit from INIT"; exit } CHECK { warn "testing exit from CHECK"; exit } #END { warn "testing exit from END"; exit } print "i am now the main program\n"; die "XXX"; You will get: % perl /tmp/a If you switch the comment on the two CHECKs, you get % perl /tmp/a --tom |
From @floatingatoll[tchrist@chthon.perl.com - Tue Mar 28 03:39:19 2000]:
Confirmed this bug is present as of @17821. |
From @chornyStill present in 5.12.0 RC0. On Tue Mar 28 03:39:19 2000, tchrist@chthon.perl.com wrote:
-- |
From @AbigailOn Mon, Apr 12, 2010 at 03:50:52AM -0700, Alexandr Ciornii via RT wrote:
And in 5.12.0-RC5 as well. However, it's not a regression for a recent It is a regression from 5.005_04 though, which will print the expected: testing exit from CHECK at bb line 14. Abigail |
From @gannett-ggreerOn Tue Mar 28 03:39:19 2000, tchrist@chthon.perl.com wrote:
The problem (as of today's Perl) is that perl_parse() returns the exit perl_parse() is flagged as public API so my patch below is unacceptable I appeal to greater powers for a "public API"-acceptable fix. :) -- |
From @gannett-ggreernak.patchdiff --git a/perl.c b/perl.c
index 0edad78..8815ed1 100644
--- a/perl.c
+++ b/perl.c
@@ -1606,11 +1606,8 @@ perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env)
call_list(oldscope, PL_unitcheckav);
if (PL_checkav)
call_list(oldscope, PL_checkav);
- ret = 0;
break;
case 1:
- STATUS_ALL_FAILURE;
- /* FALL THROUGH */
case 2:
/* my_exit() was called */
while (PL_scopestack_ix > oldscope)
@@ -1621,11 +1618,9 @@ perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env)
call_list(oldscope, PL_unitcheckav);
if (PL_checkav)
call_list(oldscope, PL_checkav);
- ret = STATUS_EXIT;
break;
case 3:
PerlIO_printf(Perl_error_log, "panic: top_env\n");
- ret = 1;
break;
}
JMPENV_POP;
|
From tchrist@perl.com +---------------------------------------------------------------------+ I'm away from the office, up in the Colorado wilderness, I'll do my best to get back to you as soon as I return. --tom |
From @HugmeirOn Sun Jul 11 00:23:23 2010, greerga wrote:
I reappeal to greater powers for a "public API"-acceptable fix. Would be |
From @wolfsageOn Fri May 04 12:15:22 2012, Hugmeir wrote:
Hmm, does this actually break the contract of the public API? The docs that I've found don't specify any specific return values, they (From perlembed.pod) So as long as perl_parse returns a false value when it succeeds, we -- Matthew Horsfall (alh) |
From @cpansproutOn Sun Nov 25 05:31:01 2012, alh wrote:
I think we need to rethink (carefully!) how perl handles this -- Father Chrysostomos |
From zefram@fysh.orgOh boy, this was a fun one. The basic problem is that the return value We can preserve most of the overloaded use of perl_parse()'s return value For users to get the correct exit code they need to interpret I have done all this (and some more) in commit -zefram |
@cpansprout - Status changed from 'open' to 'pending release' |
From zefram@fysh.orgIn order to give Module::Install distros more time to roll out a fix -zefram |
From @xsawyerxFollowing this, we should formulate a plan for dealing with these Zefram, is it possible to provide a succinct way to explain this change On 12/27/2017 11:26 PM, Zefram wrote:
|
From zefram@fysh.orgSawyer X wrote:
"Module::Install::DSL versions below 1.19 rely on a core bug, and -zefram |
From @jkeenanRe-opening ticket per discussion. |
@jkeenan - Status changed from 'pending release' to 'open' |
From @karenetheridgeUse of Module::Install is discouraged by the Perl Toolchain Gang, and it On Wed, Dec 27, 2017 at 1:46 PM, Zefram <zefram@fysh.org> wrote:
|
From @khwilliamsonOn 12/28/2017 01:19 PM, Karen Etheridge wrote:
+1
|
From @eserteKaren Etheridge <perl@froods.org> writes:
Module::Install is used by several thousand CPAN distributions. A
-- Berlin Perl Mongers - http://berlin.pm.org |
From @karenetheridgeA module being deprecated doesn't mean it will be removed from cpan (unless We already have a breakage with Module::Install since 5.26 (unless On Thu, Dec 28, 2017 at 12:43 PM, Slaven Rezic <slaven@rezic.de> wrote:
|
From @cpansproutOn Thu, 28 Dec 2017 13:05:10 -0800, perl@froods.org wrote:
But that is also the reason why deprecating the newest, fixed version of Module::Install is not an immediate problem for those several thousand distributions. They are not using it yet. -- Father Chrysostomos |
From @GrinnzOn Thu, Dec 28, 2017 at 4:43 PM, Father Chrysostomos via RT <
In this case, the main benefit of deprecation is forceful documentation -Dan |
From @jkeenanOn Thu, 28 Dec 2017 21:05:10 GMT, perl@froods.org wrote:
+1 -- |
From @jkeenanOn Wed, 27 Dec 2017 22:43:00 GMT, jkeenan wrote:
We should try to move this ticket and the related 1. The ticket was filed eighteen-and-a-half years ago by Tom 2. Zefram reported solving the bug on Dec 10 2017 3. By Dec 12 2017 CPAN breakage had been spotted -- 4. While Module::Install could be fixed and was fixed by 5. Back in RT 132577 (the BBC ticket), discussion ensued "We expect to fix the bug again during the 5.29 cycle. This In RT 2754 (this ticket), he wrote: "In order to give Module::Install distros more time to roll Pumpking Sawyer X concurred, writing: "Following this, we should formulate a plan for dealing with 6. The complicating factor in giving CPAN distributions 7. In an attempt to get some empirical data to inform this a. I created a branch, "smoke-me/jkeenan/2754-re-revert", b. I then wrote a program similar to the "test CPAN river i. Start with the same "CPAN river 3000" modules I've been ii. Remove those modules which got a non-PASS grade in last iii. Add the CPAN distributions listed as being revdeps of iv. Remove the M-I revdeps whose names begin with 'Task' or c. I ran the program yesterday in an environment similar but d. I examined the resulting data for the purpose of 8. I therefore believe that we can predict with reasonable 9. I therefore believe that we should move forward on this. a. Re-examine the chain of commits to determine whether the b. Come to consensus among P5P and Toolchain Gang as to what c. Merge the 2754-re-revert branch -- or an improved version Thank you very much. -- |
From @jkeenanOn Tue, 25 Sep 2018 14:52:40 GMT, jkeenan wrote:
TonyC, DaveM, list: Any feedback on this plan? Thank you very much. -- |
From @jkeenanOn Sat, 29 Sep 2018 23:37:56 GMT, jkeenan wrote:
sawyer, list: Any feedback on this plan? Thank you very much. -- |
From @iabynOn Sat, Sep 29, 2018 at 04:37:56PM -0700, James E Keenan via RT wrote:
The world has managed to live with this bug for at least 18 years, so -- |
From @iabynI've moved this ticket from 5.30.0 blocker to 5.32.0 blocker |
From @tonycozOn Tue, 23 Apr 2019 07:49:17 -0700, davem wrote:
Here's a revert of the revert patch. I'll apply this next week, unless there's an objection. Tony |
From @tonycoz0001-Revert-postpone-perl_parse-exit-0-bugfix.patchFrom ce6cbbca8ada5c17a3c34121fd8b896917c1a250 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 4 Jul 2019 15:02:46 +1000
Subject: Revert "postpone perl_parse() exit(0) bugfix"
This reverts commit 857320cbf85e762add18885ae8a197b5e0c21b69,
re-instating the [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
---
perl.c | 27 ++++++++-------------------
t/op/blocks.t | 12 ++++++------
2 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/perl.c b/perl.c
index 2e80cfe940..aeb259676e 100644
--- a/perl.c
+++ b/perl.c
@@ -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
*/
@@ -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");
diff --git a/t/op/blocks.t b/t/op/blocks.t
index 1fb369a1a1..ea6ca4d144 100644
--- a/t/op/blocks.t
+++ b/t/op/blocks.t
@@ -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"
);
}
--
2.11.0
|
From @tonycozOn Wed, 03 Jul 2019 22:05:40 -0700, tonyc wrote:
Applied as 2773b4f. I expect this will cause some distributions with outdated Module::Install::DSL to fail, hopefully they can be updated before 5.32.0 Tony |
Migrated from rt.perl.org#2754 (status was 'open')
Searchable as RT2754$
The text was updated successfully, but these errors were encountered: