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
[Regression] "die;" does not always propagate exception #11996
Comments
From anthony@derobert.netCreated by anthony@derobert.netThis is a bug report for perl from anthony@derobert.net, ----------------------------------------------------------------- NOTE: This is also Debian bug 663158 "die" does not always propagate the exception in $@. The below test foo at survey.cgi line 22 instead it prints Died at survey.cgi line 19. This worked in 5.12.x and 5.10.x. I have tested this on Debian's compiled perl (details below from Performing a git bisect, I found the regression was introduced by commit c5df309 SV-based interfaces for dieing and warning Test program. Note that it's very fragile. Take off -T, get rid of the ===== BEGIN TEST PROGRAM ===== use Carp qw(confess); my $CGI; sub send_template; my $dat = <<DATA; eval { run_template($CGI->param('survey_no')); }; sub run_template { Note that you can find the full bisect log, the test programs used for Perl Info
|
From @cpansproutOn Fri Mar 09 09:23:57 2012, derobert wrote:
That’s a pretty nasty regression. Can we make this a blocker for 5.16? -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Fri, Mar 09, 2012 at 01:09:54PM -0800, Father Chrysostomos via RT wrote:
I think it should be a blocker too. Tony |
From @tonycozOn Sat, Mar 10, 2012 at 03:21:29PM +1100, Tony Cook wrote:
A simpler test case: #!/usr/bin/perl -Tw |
From @tonycozOn Sun, Mar 11, 2012 at 01:19:36PM +1100, Tony Cook wrote:
Attached: regression test and possible fix. It may be that the code should be checking for magic earlier, but with Tony |
From @tonycoz0001-rt-111654-TODO-test-for-tainted-die-propagation.patchFrom 6c3816fb002c13b546764174e8576b2012725cdf Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Sun, 11 Mar 2012 14:27:29 +1100
Subject: [PATCH 1/2] [rt #111654] TODO test for tainted die propagation
---
t/op/taint.t | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/t/op/taint.t b/t/op/taint.t
index 1b75439..095c991 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -17,7 +17,7 @@ BEGIN {
use strict;
use Config;
-plan tests => 793;
+plan tests => 794;
$| = 1;
@@ -2197,6 +2197,15 @@ pass("no death when TARG of ref is tainted");
is_tainted "\F$utf8", "under locale, \\Futf8 taints the result";
}
+{ # 111654
+ local $::TODO = "RT #111654";
+ eval {
+ eval { die "Test\n".substr($ENV{PATH}, 0, 0); };
+ die;
+ };
+ like($@, qr/^Test\n\t\.\.\.propagated at /, "error should be propagated");
+}
+
# This may bomb out with the alarm signal so keep it last
SKIP: {
skip "No alarm()" unless $Config{d_alarm};
--
1.7.2.5
|
From @tonycoz0002-rt-111654-properly-propgate-tainted-errors.patchFrom e00ad30ae2b8f545e4f96cab8e76ccd74840e687 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Sun, 11 Mar 2012 14:38:57 +1100
Subject: [PATCH 2/2] [rt #111654] properly propgate tainted errors
A magic value (such as a tainted string) may not have POK set, so call
SvPV() to find out if there's something in ERRSV to report.
Possibly this should be using SvPV_nomg(), but this is the first
request for magic in this code. Maybe the code above should be
calling SvGETMAGIC() before checking SvROK().
---
pp_sys.c | 2 +-
t/op/taint.t | 1 -
2 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/pp_sys.c b/pp_sys.c
index 63fbd05..83fe34d 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -500,7 +500,7 @@ PP(pp_die)
}
}
}
- else if (SvPOK(ERRSV) && SvCUR(ERRSV)) {
+ else if (SvPV(ERRSV, len) && len) {
exsv = sv_mortalcopy(ERRSV);
sv_catpvs(exsv, "\t...propagated");
}
diff --git a/t/op/taint.t b/t/op/taint.t
index 095c991..9cea740 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -2198,7 +2198,6 @@ pass("no death when TARG of ref is tainted");
}
{ # 111654
- local $::TODO = "RT #111654";
eval {
eval { die "Test\n".substr($ENV{PATH}, 0, 0); };
die;
--
1.7.2.5
|
From @rjbsThis blocks 5.16.0 |
From @cpansproutOn Sat Mar 10 19:45:35 2012, tonyc wrote:
Checking for magic earlier before the SvROK check would be the correct If you are going to use SvPV, I believe it always returns true, so what Interestingly, using SvPV fixes this bug, too: $ perl5.14.0 -e '$@ = 3; die' -- Father Chrysostomos |
From zefram@fysh.orgTony Cook wrote:
Yes, this looks right. There are many kinds of scalar that are not POK -zefram |
@tonycoz - Status changed from 'open' to 'resolved' |
From @jmdhOn Sun, Mar 11, 2012 at 04:39:27PM -0700, Tony Cook via RT wrote:
And queued in Debian's git (simple backport to 5.14 which just needed http://anonscm.debian.org/gitweb/?p=perl/perl.git;a=commit;h=e6d732e0cdea0d6906b732628f6a55f93f91f633 -- |
Migrated from rt.perl.org#111654 (status was 'resolved')
Searchable as RT111654$
The text was updated successfully, but these errors were encountered: