Closed p5pRT closed 18 years ago
perl -le '$_="65x"; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x Ax 4178
This is normal.
perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x A 4100
Where did the second x go ????
-----BEGIN PGP SIGNED MESSAGE-----
Moin\,
[Please enter your report here]
perl -le '$_="65x"; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x Ax 4178
This is normal.
perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x A 4100
Where did the second x go ????
Confirmed on v5.8.1 and v5.8.2.
Cheers\,
Tels
- -- Signed on Sat Dec 20 21:55:18 2003 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email.
"Call me Justin\, Justin Case."
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) Comment: When cryptography is outlawed\, bayl bhgynjf jvyy unir cevinpl.
iQEVAwUBP+S3encLPEOTuEwVAQGE7Af+PdAqt3NEBJHj3JXMYeXy6Abjs21BPNQM g0VWYWXn+8zXi5qvpLEPFP1cUOqVTVaqC4C/T4gLI60utdNdr9JUZT47nftJk9Bz 8Ct47wf5tiOSzJt4qjFKJ8bhIkA0GcDNwiEGLXkoCM1GdtyAbeGKs9KfZSyuLews 4CcPrSiViPdK7WPr/aV5CX3fF3mfQ7sIQ/hI3hU+EKQmoOlpH0AI246IwHw9MhF5 5xm8ikikGAh3nIyDt65Da6m2IKPaT0SZNEv06hr7mkDG8jO8EkdvvbqhZVZ/kwAn PXm1C8QbCotslQ5R/x7OA7EEnXmmqebmdBmpzP62SOoO6Hyqyi9rMw== =2GmU -----END PGP SIGNATURE-----
----------------------------------------------------------------- [Please enter your report here]
perl -le '$_="65x"; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x Ax 4178
This is normal.
perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x A 4100
Where did the second x go ????
[Please do not change anything below this line]
Instead of s/x///\, substr($_\,0\,1\,"") causes the same result. It seems to be related to an offset OK string.
perl -le '$_="x65x"; substr($_\,0\,1\,""); print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x A 4100
I tested with various numbers of bytes before and after "65"\, where initial value of $_ would be "ab65z"\, "abc65xyz"\, and so on.
The offset value is set to $numOfCharsBefore65. In this case\, if $numOfCharsBefore65 >= $numOfCharsAfter65\, this problem occurs.
#!perl for my $numOfCharsBefore65 (1..5) { for my $numOfCharsAfter65 (1..5) { my $prefix = substr("abcdefghijklm"\, 0\, $numOfCharsBefore65); my $suffix = substr("nopqrstuvwxyz"\, -$numOfCharsAfter65); print "$numOfCharsBefore65\,$numOfCharsAfter65\t";
$_ = $prefix.'65'.$suffix; substr($_\,0\,$numOfCharsBefore65\,''); # remove $prefix print "$_\t"; # should be '65'.$suffix s/65/chr/e; print "$_\t"; print unpack("H*"\, $_)\, "\n"; } } __END__
1\,1 65z A 4100 1\,2 65yz Az 417a00 1\,3 65xyz Ayz 41797a00 1\,4 65wxyz Axyz 4178797a00 1\,5 65vwxyz Awxyz 417778797a00 2\,1 65z Az 417a 2\,2 65yz A z 41007a 2\,3 65xyz Az z 417a007a 2\,4 65wxyz Ayz z 41797a007a 2\,5 65vwxyz Axyz z 4178797a007a 3\,1 65z Az 417a 3\,2 65yz Ayz 41797a 3\,3 65xyz A yz 4100797a 3\,4 65wxyz Az yz 417a00797a 3\,5 65vwxyz Ayz yz 41797a00797a 4\,1 65z Az 417a 4\,2 65yz Ayz 41797a 4\,3 65xyz Axyz 4178797a 4\,4 65wxyz A xyz 410078797a 4\,5 65vwxyz Az xyz 417a0078797a 5\,1 65z Az 417a 5\,2 65yz Ayz 41797a 5\,3 65xyz Axyz 4178797a 5\,4 65wxyz Awxyz 417778797a 5\,5 65vwxyz A wxyz 41007778797a
Regards\, SADAHIRO Tomoyuki
On Sun\, 21 Dec 2003 14:14:53 +0900 SADAHIRO Tomoyuki \bqw10602@​nifty\.com wrote:
I tested with various numbers of bytes before and after "65"\, where initial value of $_ would be "ab65z"\, "abc65xyz"\, and so on.
The offset value is set to $numOfCharsBefore65. In this case\, if $numOfCharsBefore65 >= $numOfCharsAfter65\, this problem occurs.
Sorry\, "if $numOfCharsBefore65 \<= $numOfCharsAfter65" is correct. ~~~~
#!perl for my $numOfCharsBefore65 (1..5) { for my $numOfCharsAfter65 (1..5) { my $prefix = substr("abcdefghijklm"\, 0\, $numOfCharsBefore65); my $suffix = substr("nopqrstuvwxyz"\, -$numOfCharsAfter65); print "$numOfCharsBefore65\,$numOfCharsAfter65\t";
$\_ = $prefix\.'65'\.$suffix; substr\($\_\,0\,$numOfCharsBefore65\,''\); \# remove $prefix print "$\_\\t"; \# should be '65'\.$suffix s/65/chr/e; print "$\_\\t"; print unpack\("H\*"\, $\_\)\, "\\n"; \}
} __END__
1\,1 65z A 4100 1\,2 65yz Az 417a00 1\,3 65xyz Ayz 41797a00 1\,4 65wxyz Axyz 4178797a00 1\,5 65vwxyz Awxyz 417778797a00 2\,1 65z Az 417a 2\,2 65yz A z 41007a 2\,3 65xyz Az z 417a007a 2\,4 65wxyz Ayz z 41797a007a 2\,5 65vwxyz Axyz z 4178797a007a 3\,1 65z Az 417a 3\,2 65yz Ayz 41797a 3\,3 65xyz A yz 4100797a 3\,4 65wxyz Az yz 417a00797a 3\,5 65vwxyz Ayz yz 41797a00797a 4\,1 65z Az 417a 4\,2 65yz Ayz 41797a 4\,3 65xyz Axyz 4178797a 4\,4 65wxyz A xyz 410078797a 4\,5 65vwxyz Az xyz 417a0078797a 5\,1 65z Az 417a 5\,2 65yz Ayz 41797a 5\,3 65xyz Axyz 4178797a 5\,4 65wxyz Awxyz 417778797a 5\,5 65vwxyz A wxyz 41007778797a
Regards\, SADAHIRO Tomoyuki
The problem here is that the subst context sb_s is pointing to parts of the PV\, but the PVIV upgrade moves the text in the PV\, so the subst context sb_s is still pointing to where it used to be.
A simple (but not great) fix is to remove the OOK before we mess with the sv.
If you're feeling paranoid, a safer place to unOOK is much closer to the start of pp_subst\, just before we take the first pointer to the inside of the PV.
Marty
On Sun\, Dec 21\, 2003 at 10:39:50PM +0000\, Marty Pauley wrote:
If you're feeling paranoid\, a safer place to unOOK is much closer to the start of pp_subst\, just before we take the first pointer to the inside of the PV.
What do I do if I'm feeling really paranoid\, and wondering if there are a whole class of bugs like these?
[taking pointers to the insides of SVs that are then moved around because of upgrading. Hack the core to create all scalars as OOK\, and see which tests fail?]
Nicholas Clark
On Sun Dec 21 22:57:34 2003\, Nicholas Clark wrote:
On Sun\, Dec 21\, 2003 at 10:39:50PM +0000\, Marty Pauley wrote:
If you're feeling paranoid\, a safer place to unOOK is much closer to the start of pp_subst\, just before we take the first pointer to the inside of the PV.
What do I do if I'm feeling really paranoid\, and wondering if there are a whole class of bugs like these?
I think there might be a few more like this. We could also get similar problems when we grow the sv and cause the pv to change altogether. We should get a segmentation fault in that case.
The thing that worried me the most about this one was that there were cases that hit the bug but still 'worked': when the offset was larger than the remainder of the string\, the move wouldn't overwrite the old part of the string.
[taking pointers to the insides of SVs that are then moved around because of upgrading. Hack the core to create all scalars as OOK\, and see which tests fail?]
That might be a good start. :-)
If we had a version of Move that filled the source with rubbish\, we might be able to find some more bugs. And if we changed sv_backoff and sv_grow to release memory when they could\, we might get some nice segmentation faults to indicate bugs.
-- Marty
On Sun\, Dec 21\, 2003 at 11:40:10PM +0000\, Marty Pauley wrote:
On Sun Dec 21 22:57:34 2003\, Nicholas Clark wrote: If we had a version of Move that filled the source with rubbish\, we might be able to find some more bugs. And if we changed sv_backoff and sv_grow to release memory when they could\, we might get some nice segmentation faults to indicate bugs.
Strictly we'd want a version of Copy that filled the source with rubbish (or bit flipped it it or something)\, as Copy is for non-overlapping cases. Move would have to be more clever and selectively trash only the non-overlapping parts.
But it's a suitably evil idea. If no-one gets there first I'll try it\, once I acquire some copious free time.
Nicholas Clark
If I rewrite the test to not use chr() but something that existed in perl4\, say
$_="65x"; s/65/$_-65/e; $res1 = $_; $_="x65x"; s/x//; s/65/$_-65/e; $res2 = $_; print $res1 eq $res2 ? "ok\n" : "not ok res1[$res1]res2[$res2]\n";
then I see the same result in perl4 as in bleed:
not ok res1[0x]res2[0]
-- andreas
[perl-5.8.0@ton.iguana.be - Fri Dec 19 13:16:25 2003]:
This is a bug report for perl from perl-5.8.0@ton.iguana.be\, generated with the help of perlbug 1.34 running under perl v5.8.0.
----------------------------------------------------------------- [Please enter your report here]
perl -le '$_="65x"; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x Ax 4178
This is normal.
perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x A 4100
Where did the second x go ????
It looks like somewhere in Dave's modifications\, this bug has been fixed.
perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x A 4100 ./perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x Ax 4178
@smpeters - Status changed from 'open' to 'resolved'
On Mon\, Apr 17\, 2006 at 10:41:27AM -0700\, Steve Peters via RT wrote:
[perl-5.8.0@ton.iguana.be - Fri Dec 19 13:16:25 2003]:
This is a bug report for perl from perl-5.8.0@ton.iguana.be\, generated with the help of perlbug 1.34 running under perl v5.8.0.
----------------------------------------------------------------- [Please enter your report here]
perl -le '$_="65x"; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x Ax 4178
This is normal.
perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x A 4100
Where did the second x go ????
It looks like somewhere in Dave's modifications\, this bug has been fixed.
Nothing to do with me! It got fixed somewhere in one of these:
Change 27276 on 2006/02/23 by nicholas@profane 'Fix the copy sizes for PVFM and'
Change 27275 on 2006/02/22 by nicholas@entropy 'In Perl_sv_dup\, merge the copy '
Change 27274 on 2006/02/22 by nicholas@profane 'Fix typos and a missing bracket'
Change 27273 on 2006/02/22 by nicholas@profane 'Avoid C\
-- Technology is dominated by two types of people: those who understand what they do not manage\, and those who manage what they do not understand.
On Mon\, Apr 17\, 2006 at 07:23:26PM +0100\, Dave Mitchell wrote:
On Mon\, Apr 17\, 2006 at 10:41:27AM -0700\, Steve Peters via RT wrote:
[perl-5.8.0@ton.iguana.be - Fri Dec 19 13:16:25 2003]:
This is a bug report for perl from perl-5.8.0@ton.iguana.be\, generated with the help of perlbug 1.34 running under perl v5.8.0.
----------------------------------------------------------------- [Please enter your report here]
perl -le '$_="65x"; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x Ax 4178
This is normal.
perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print unpack("H*"\, $_)' 65x A 4100
Where did the second x go ????
It looks like somewhere in Dave's modifications\, this bug has been fixed.
Nothing to do with me! It got fixed somewhere in one of these:
It's this one:
Change 27270 on 2006/02/22 by rgs@marais 'Turn on match string copying wh'
Change 27270 by rgs@marais on 2006/02/22 20:28:41
Turn on match string copying when /e flag is set on a substitution.
Subject: [PATCH] dodge a valgrind error (for maint or blead) From: Jarkko Hietaniemi \jhietaniemi@​gmail\.com Date: Feb 22\, 2006 8:16 PM Message-ID: \43FCB896\.7060106@​gmail\.com
Affected files ...
... //depot/perl/pp_hot.c#455 edit
Differences ...
==== //depot/perl/pp_hot.c#455 (text) ====
@@ -1335\,7 +1335\,7 @@ } } if ((!global && rx->nparens) - || SvTEMP(TARG) || PL_sawampersand) + || SvTEMP(TARG) || PL_sawampersand || (pm->op_pmflags & PMf_EVAL)) r_flags |= REXEC_COPY_STR; if (SvSCREAM(TARG)) r_flags |= REXEC_SCREAM; @@ -2101\,7 +2101\,8 @@ pm = PL_curpm; rx = PM_GETRE(pm); } - r_flags = (rx->nparens || SvTEMP(TARG) || PL_sawampersand) + r_flags = (rx->nparens || SvTEMP(TARG) || PL_sawampersand + || (pm->op_pmflags & PMf_EVAL)) ? REXEC_COPY_STR : 0; if (SvSCREAM(TARG)) r_flags |= REXEC_SCREAM;
I'm not sure why that fixes it. For the example code\, valgrind makes no complaint with or without the change.
Nicholas Clark
Migrated from rt.perl.org#24704 (status was 'resolved')
Searchable as RT24704$