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
foreach variable referenced in format segfaults #6545
Comments
From kjetilho@ifi.uio.noThis is a bug report for perl from kjetilho@ifi.uio.no, [Please enter your report here] this script will dump core on both Solaris and Linux. it works format STDOUT = |
From @nwc10On Thu, May 29, 2003 at 08:40:19PM -0000, kjetilho@ifi.uio.no (via RT) wrote:
D'oh! to perlbug (as you report in bug 22373) Thanks, Nicholas Clark |
From kjetilho@ifi.uio.no
clearly perlbug doesn't handle reports with solitary periods ... format STDOUT = %hash = ("k" => "v"); this works: format STDOUT = %hash = ("k" => "v"); -- |
From kjetilho@ifi.uio.no(I already sent this once, <1rhe7dxz0i.fsf@vingodur.ifi.uio.no>, not let's try again. this crashes: format STDOUT = %hash = ("k" => "v"); this works: format STDOUT = %hash = ("k" => "v"); -- |
From @andkKjetil Torgrim Homme <kjetilho@ifi.uio.no> writes:
One workaround against the sendmail problem should be to replace the The other workaround is, of course, just to indent the whole program -- |
From enache@rdslink.roOn Fri, May 30, 2003 at 12:41:48AM +0200, Kjetil Torgrim Homme wrote:
Have a look at these snippets from sv_chop(): register STRLEN delta; Both SV_CHECK_THINKFIRST and SvGROW may reallocate SvPVX(sv) elsewhere; Regards, Inline Patch--- /arc/bleadperl/sv.c 2003-05-13 02:03:25.000000000 +0300
+++ ./sv.c 2003-05-30 17:21:22.000000000 +0300
@@ -4501,6 +4501,8 @@ Efficient removal of characters from the
SvPOK(sv) must be true and the C<ptr> must be a pointer to somewhere inside
the string buffer. The C<ptr> becomes the first character of the adjusted
string. Uses the "OOK hack".
+Beware: after this function returns, C<ptr> and SvPVX(sv) may no longer
+refer to the same chunk of data.
=cut
*/
@@ -4509,9 +4511,9 @@ void
Perl_sv_chop(pTHX_ register SV *sv, register char *ptr)
{
register STRLEN delta;
-
if (!ptr || !SvPOKp(sv))
return;
+ delta = ptr - SvPVX(sv);
SV_CHECK_THINKFIRST(sv);
if (SvTYPE(sv) < SVt_PVIV)
sv_upgrade(sv,SVt_PVIV);
@@ -4531,7 +4533,6 @@ Perl_sv_chop(pTHX_ register SV *sv, regi
SvFLAGS(sv) |= SVf_OOK;
}
SvNIOK_off(sv);
- delta = ptr - SvPVX(sv);
SvLEN(sv) -= delta;
SvCUR(sv) -= delta;
SvPVX(sv) += delta;
--- /arc/bleadperl/t/op/write.t 2002-04-29 00:31:14.000000000 +0300
+++ ./t/op/write.t 2003-05-30 18:39:45.000000000 +0300
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..47\n";
+print "1..48\n";
my $CAT = ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS') ? 'type'
: ($^O eq 'MacOS') ? 'catenate'
@@ -271,7 +271,19 @@ if (`$CAT Op_write.tmp` eq $right)
else
{ print "not ok 11\n"; }
-# 12..47: scary format testing from Merijn H. Brand
+{
+ my $el;
+ format STDOUT =
+ok ^<<<<<<<<<<<<<<~~ # sv_chop() naze
+$el
+.
+ my %hash = (12 => 3);
+ for $el (keys %hash) {
+ write;
+ }
+}
+
+# 13..48: scary format testing from Merijn H. Brand
if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'MacOS' ||
($^O eq 'os2' and not eval '$OS2::can_fork')) {
@@ -281,7 +293,7 @@ if ($^O eq 'VMS' || $^O eq 'MSWin32' ||
use strict; # Amazed that this hackery can be made strict ...
-my $test = 12;
+my $test = 13;
# Just a complete test for format, including top-, left- and bottom marging
# and format detection through glob entries |
From @iabynOn Thu, May 29, 2003 at 10:45:49PM +0200, Kjetil Torgrim Homme wrote:
This is due to keys returning a shared hash string SV, and pp_formline() That's what the problem is; I don't understand enough about all this Dave -- |
From enache@rdslink.roOn Sat, May 31, 2003 at 12:18:33AM +0100, Dave Mitchell wrote:
Have a look at my reply/patch to this The way sv_chop() sometimes builds a OOK-hacked SV from scratch still Regards, |
From @rgsEnache Adrian wrote:
This outputs nothing for me.
|
From @nwc10On Sat, May 31, 2003 at 11:10:56AM +0200, Rafael Garcia-Suarez wrote:
I was playing with trying to make a regression test last night I was thinking that the only reliable way I could think of to make sure Nicholas Clark |
From enache@rdslink.roOn Sat, May 31, 2003 at 11:10:56AM +0200, Rafael Garcia-Suarez wrote:
That's curious, because blead ~ 19600 just worked.
Oops. Inline Patch--- /arc/bleadperl/t/op/write.t 2002-04-29 00:31:14.000000000 +0300
+++ ./t/op/write.t 2003-05-31 14:10:11.000000000 +0300
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..47\n";
+print "1..48\n";
my $CAT = ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS') ? 'type'
: ($^O eq 'MacOS') ? 'catenate'
@@ -271,17 +271,29 @@ if (`$CAT Op_write.tmp` eq $right)
else
{ print "not ok 11\n"; }
-# 12..47: scary format testing from Merijn H. Brand
+{
+ our $el;
+ format STDOUT =
+ok ^<<<<<<<<<<<<<<~~ # sv_chop() naze
+$el
+.
+ my %hash = (12 => 3);
+ for $el (keys %hash) {
+ write;
+ }
+}
+
+# 13..48: scary format testing from Merijn H. Brand
if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'MacOS' ||
($^O eq 'os2' and not eval '$OS2::can_fork')) {
- foreach (12..47) { print "ok $_ # skipped: '|-' and '-|' not supported\n"; }
+ foreach (13..48) { print "ok $_ # skipped: '|-' and '-|' not supported\n"; }
exit(0);
}
use strict; # Amazed that this hackery can be made strict ...
-my $test = 12;
+my $test = 13;
# Just a complete test for format, including top-, left- and bottom marging
# and format detection through glob entries |
From enache@rdslink.roOn Sat, May 31, 2003 at 02:18:11PM +0300, Enache Adrian wrote:
Another example: blead@19582, 5.8.0 : (4 ) Regards, |
From @rgsEnache Adrian wrote:
Qualifies as a bug. Maybe the jumbo closure patch (19367) is
"naze" really sounds like french slang, doesn't it ? |
@rspier - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#22372 (status was 'resolved')
Searchable as RT22372$
The text was updated successfully, but these errors were encountered: