Closed p5pRT closed 21 years ago
The bug is clearly demonstrate by the following snippet. The first call to swap() gives the correct result. A second call results in a completely different result despite that there *should* be no connection between the operands of the two calls.
Somehow\, the first call leaves the internal state of perl such that a second call with entirely different parameters\, is affected. Comment out the first call\, and the second call functions as desired.
\
The bug has been verified as present under 5.8 on linux as well as AS 5.8.
#! perl -slw use strict;
sub swab{ substr( $_[0]\, $_[1]\, 1 ) ^= substr( $_[0]\, $_[2]\, 1 ) ^= substr( $_[0]\, $_[1]\, 1 ) ^= substr( $_[0]\, $_[2]\, 1 ) }
my $s ='AB'; swab( $s\, 0\, 1 ); print "'$s'"; print "'$s'";
my $t ='AB'; print "'$t'"; swab( $t\, 0\, 1 ); print "'$t'"; print "'$t'";
__END__ P:\test>junk 'BA' 'BA' 'AB' ' A' ' A'
On Sun\, Aug 03\, 2003 at 04:36:22AM -0000\, va0hs001@sneakemail.com (via RT) wrote:
# New Ticket Created by va0hs001@sneakemail.com # Please include the string: [perl #23207] # in the subject line of all future correspondence about this issue. # \<URL: http://rt.perl.org/rt2/Ticket/Display.html?id=23207 >
This is a bug report for perl from zmcj0g5a001@sneakemail.com\, generated with the help of perlbug 1.34 running under perl v5.8.0.
----------------------------------------------------------------- [Please enter your report here]
The bug is clearly demonstrate by the following snippet. The first call to swap() gives the correct result. A second call results in a completely different result despite that there *should* be no connection between the operands of the two calls.
Somehow\, the first call leaves the internal state of perl such that a second call with entirely different parameters\, is affected. Comment out the first call\, and the second call functions as desired.
\
The bug has been verified as present under 5.8 on linux as well as AS 5.8.
#! perl -slw use strict;
sub swab{ substr( $_[0]\, $_[1]\, 1 ) ^= substr( $_[0]\, $_[2]\, 1 ) ^= substr( $_[0]\, $_[1]\, 1 ) ^= substr( $_[0]\, $_[2]\, 1 ) }
my $s ='AB'; swab( $s\, 0\, 1 ); print "'$s'"; print "'$s'";
my $t ='AB'; print "'$t'"; swab( $t\, 0\, 1 ); print "'$t'"; print "'$t'";
__END__ P:\test>junk 'BA' 'BA' 'AB' ' A' ' A'
It seems to be doing this at least from version 5.005\, and still present in bleadperl and 5.8.1-RC4. However\, I don't get " A" as a result\, but "\x00A".
Abigail
Please try the patch below.
Basically\, the targets of the substr OPs point to same SVs - and their SvPOK flags are not cleared after use. The second time the swab sub is run\, they'll show up as valid string scalars and won't trigger their magic get method in doop:1111::Perl_do_vop.
lsave = lc = SvPV(left\, leftlen);
Regards\, Adi
Enache Adrian wrote:
Please try the patch below.
Basically\, the targets of the substr OPs point to same SVs - and their SvPOK flags are not cleared after use. The second time the swab sub is run\, they'll show up as valid string scalars and won't trigger their magic get method in doop:1111::Perl_do_vop.
Thanks\, applied as #20462.
@rgs - Status changed from 'new' to 'resolved'
Migrated from rt.perl.org#23207 (status was 'resolved')
Searchable as RT23207$