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
5.10.0 functionality change and segfault #9732
Comments
From @gbarrCreated by @gbarrI have not been able to track down the exact cause yet, but the following demonstrates $ cat test type(*DATA); $ /apps/perl-5.8.9/bin/perl test $ /apps/perl-5.10.0/bin/perl test When compiled with debugging, and assert fails Assertion ((buffer)->sv_flags & 0x00000400) failed: file "sv.c", line 1741 at test line 5. Perl Info
|
From @nwc10On Mon, May 11, 2009 at 08:59:20PM -0700, Graham Barr wrote:
Yes, that's interesting. I think it has to be a bug in 5.8.9 and earlier that $ perl -MDevel::Peek -le 'print $]; $a = *STDIN{IO}; $b = *$a; print defined $b; print length $b' 0 How can something not be defined, yet stringify to "" without warning? Your testcase pinpoints the cause of the SEGV - it's an unexpected interaction void PERL_ARGS_ASSERT_GV_FULLNAME4; if (!hv) { and this call to it: SvFAKE_off(gv); assert(SvPOK(buffer)); The problem is that the "obvious" fix ends up with just a reversal of the Nicholas Clark |
The RT System itself - Status changed from 'new' to 'open' |
From @gbarrOn May 12, 2009, at 3:12 PM, Nicholas Clark via RT wrote:
because you did not add -w to the command line adding -w I se the warning as far back as /apps/perl-5.4.5/bin/perl5.00405 Use of uninitialized value at -e line 1. However note that a Dump($b) is different in blead then 5.8.9 blead: SV = PVGV(0x89be768) at 0x89ad580 5.8.9: SV = PVGV(0x90caa3c) at 0x90b3b7c I have not followed closely enough to know if that dropping of magic Graham.
|
From @nwc10On Tue, May 12, 2009 at 04:24:28PM -0500, Graham Barr wrote:
Totally intentional. 24+ bytes used per typeglob (hence per sub or method) http://perl5.git.perl.org/perl.git/commit/180488f8452e93d2afa0f62b189be1cc9ac6 Nicholas Clark |
From @gbarrOn May 12, 2009, at 5:41 PM, Nicholas Clark wrote:
Sure, OK. As I said I had not been following closely. I have done a little more digging It seems to me that the root of this issue is that gv_init(gv, 0, "", 0, 0); after this, in blead SvOK(gv) returns true, but in 5.8.9 SvOK(gv) is this is why defined($y) is true on 5.10.0 but false on 5.8.x and before While not a fix, because lib/Benchmark and op/tie fail, I put in a The result was that the following matches 5.8.x and before $ ./perl -wle '$x = *STDIN{IO}; $y = *$x; print "$x"; print "$y"' Graham. |
From @gbarrOn May 13, 2009, at 12:52 AM, Graham Barr wrote:
However, the following is still different $ perl5.8.9 -wle '$x = *STDERR{IO}; $y = *$x; print "$x"; print $ ./perl -wle '$x = *STDERR{IO}; $y = *$x; print "$x"; print Use of uninitialized value $y in string at -e line 1. So $y was undefined but still valid for use as a filehandle (time to seep) |
From @nwc10Dave notes: Fine in 5.8.8,5.8.9; assert fails in 5.10.0, maint, blead. Nick notes: I have some idea of what's going on here. |
From p5p@spam.wizbit.beBinary searches: There appears to be two changes: ----Program---- sub type { type(*DATA); ----Output of .../pPSPFBH/perl-5.9.3@27276/bin/perl---- ----EOF ($?='0')---- ----EOF ($?='0')---- http://public.activestate.com/cgi-bin/perlbrowse/p/27278 Remove get magic from typeglobs. This means that PVGVs holding ----Program---- sub type { type(*DATA); ----Output of .../pP16HNv/perl-5.9.3@27802/bin/perl---- ----EOF ($?='0')---- ----EOF ($?='11')---- http://public.activestate.com/cgi-bin/perlbrowse/p/27803 S_glob_2inpuv() did not check if lenp was NULL. Oops. (all perls compiled without -DDEBUGGING) |
From @iabynOn Wed, May 13, 2009 at 01:13:12AM -0500, Graham Barr wrote:
I've applied the following commit, which I hope makes for sensible commit 1809c94 fix for [perl #65582] anon globs segfaulting Affected files ... Differences ... Inline Patchdiff --git a/sv.c b/sv.c
index 063dd19..4e80e18 100644
--- a/sv.c
+++ b/sv.c
@@ -2986,11 +2986,17 @@ Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN *const lp, const I32 flags
gv_efullname3(buffer, gv, "*");
SvFLAGS(gv) |= wasfake;
- assert(SvPOK(buffer));
- if (lp) {
- *lp = SvCUR(buffer);
+ if (SvPOK(buffer)) {
+ if (lp) {
+ *lp = SvCUR(buffer);
+ }
+ return SvPVX(buffer);
+ }
+ else {
+ if (lp)
+ *lp = 0;
+ return (char *)"";
}
- return SvPVX(buffer);
}
if (lp)
diff --git a/t/op/gv.t b/t/op/gv.t
index 1b705ef..72787c4 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -12,7 +12,7 @@ BEGIN {
use warnings;
require './test.pl';
-plan( tests => 178 );
+plan( tests => 181 );
# type coersion on assignment
$foo = 'foo';
@@ -560,6 +560,27 @@ foreach my $type (qw(integer number string)) {
"with the correct error message");
}
+# RT #60954 anonymous glob should be defined, and not coredump when
+# stringified. The behaviours are:
+#
+# defined($glob) "$glob"
+# 5.8.8 false "" with uninit warning
+# 5.10.0 true (coredump)
+# 5.12.0 true ""
+
+{
+ my $io_ref = *STDOUT{IO};
+ my $glob = *$io_ref;
+ ok(defined $glob, "RT #60954 anon glob should be defined");
+
+ my $warn = '';
+ local $SIG{__WARN__} = sub { $warn = $_[0] };
+ use warnings;
+ my $str = "$glob";
+ is($warn, '', "RT #60954 anon glob stringification shouln't warn");
+ is($str, '', "RT #60954 anon glob stringification should be empty");
+}
+
__END__
Perl
Rules
-- Red sky at night - gerroff my land! |
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#65582 (status was 'resolved')
Searchable as RT65582$
The text was updated successfully, but these errors were encountered: