Bug 429531 - perl incorrect calculation
perl incorrect calculation
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: perl (Show other bugs)
8
All Linux
low Severity low
: ---
: ---
Assigned To: Marcela Mašláňová
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-01-21 07:41 EST by Need Real Name
Modified: 2008-03-16 20:56 EDT (History)
5 users (show)

See Also:
Fixed In Version: perl-5.8.8-33.fc8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-03-13 09:58:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
test program (1.63 KB, text/plain)
2008-01-21 07:43 EST, Need Real Name
no flags Details
simplified test (405 bytes, text/plain)
2008-01-21 07:50 EST, Need Real Name
no flags Details

  None (edit)
Description Need Real Name 2008-01-21 07:41:29 EST
perl-5.8.8-31 and all other 5.8.8 series execute attached code incorrectly

It produces the output:

Use of uninitialized value in concatenation (.) or string at test.pl line 71.
TBN= A=<DATA>T1<ENDMID></end> TXT 
Use of uninitialized value in concatenation (.) or string at test.pl line 71.
TBN= A=<DATA>T2<ENDMID></end> TXT 
Use of uninitialized value in concatenation (.) or string at test.pl line 71.
TBN= A=<DATA>T3<ENDMID></end> TXT 
Use of uninitialized value in concatenation (.) or string at test.pl line 71.
TBN= A=<DATA>T4<ENDMID></end> TXT 
Use of uninitialized value in concatenation (.) or string at test.pl line 71.
TBN= A=<DATA>T5<ENDMID></end> TXT 
Use of uninitialized value in concatenation (.) or string at test.pl line 71.
TBN= A=<DATA>T6<ENDMID></end> TXT 


when I replace the 
my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg;
by exactly the same meaning:
my $x=$a;
my($tmpbname)=$x=~m@<DATA>([^<>]*)@isg;

the program produces correct output

TBN=T1 A=<APARTMENT>T1<ENDMID></end> TXT 
TBN=T2 A=<APARTMENT>T2<ENDMID></end> TXT 
TBN=T3 A=<APARTMENT>T3<ENDMID></end> TXT 
TBN=T4 A=<APARTMENT>T4<ENDMID></end> TXT 
TBN=T5 A=<APARTMENT>T5<ENDMID></end> TXT 
TBN=T6 A=<APARTMENT>T6<ENDMID></end> TXT 


Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Need Real Name 2008-01-21 07:43:33 EST
Created attachment 292361 [details]
test program

perl -w test.pl
then comment 
my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg;
and uncomment

my $x=$a;
my($tmpbname)=$x=~m@<DATA>([^<>]*)@isg;
and perl -w test.pl 
again
Comment 2 Need Real Name 2008-01-21 07:50:29 EST
Created attachment 292362 [details]
simplified test

output 1
my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg;

Use of uninitialized value in concatenation (.) or string at test2.pl line 28.
TBN= A=<DATA>J1</END>
Use of uninitialized value in concatenation (.) or string at test2.pl line 28.
TBN= A=<DATA>J2</END>
Use of uninitialized value in concatenation (.) or string at test2.pl line 28.
TBN= A=<DATA>J3</END>
Use of uninitialized value in concatenation (.) or string at test2.pl line 28.
TBN= A=<DATA>J4</END>
Use of uninitialized value in concatenation (.) or string at test2.pl line 28.
TBN= A=<DATA>J5</END>

output 2 
my $x=$a;
my($tmpbname)=$x=~m@<DATA>([^<>]*)@isg;

TBN=J1 A=<DATA>J1</END>
TBN=J2 A=<DATA>J2</END>
TBN=J3 A=<DATA>J3</END>
TBN=J4 A=<DATA>J4</END>
TBN=J5 A=<DATA>J5</END>
Comment 3 Jan Pazdziora 2008-02-28 08:05:22 EST
The test program from comment 2 works on on Fedora 8 with

$ rpm -q perl
perl-5.8.8-33.fc8.x86_64

Proposing to close with CURRENTRELEASE.
Comment 4 Need Real Name 2008-03-01 08:17:58 EST
On F7 it does not produce correct output. I did not try yet on F8.

# rpm -q perl
perl-5.8.8-28.fc7
# perl -w test2.pl
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J1</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J2</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J3</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J4</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J5</END>
Comment 5 Need Real Name 2008-03-01 08:58:26 EST
The probles IS NOT FIXED IN
 rpm -q perl
perl-5.8.8-33.fc8

# perl -w test2.pl 
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J1</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J2</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J3</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J4</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J5</END>

The output IS INCORRECT
Comment 6 Jan Pazdziora 2008-03-03 03:20:58 EST
(In reply to comment #5)
> The probles IS NOT FIXED IN
>  rpm -q perl
> perl-5.8.8-33.fc8
> 
> # perl -w test2.pl 
> Use of uninitialized value in concatenation (.) or string at attachment.cgi
line 28.
> TBN= A=<DATA>J1</END>
> Use of uninitialized value in concatenation (.) or string at attachment.cgi
line 28.
> TBN= A=<DATA>J2</END>
> Use of uninitialized value in concatenation (.) or string at attachment.cgi
line 28.
> TBN= A=<DATA>J3</END>
> Use of uninitialized value in concatenation (.) or string at attachment.cgi
line 28.
> TBN= A=<DATA>J4</END>
> Use of uninitialized value in concatenation (.) or string at attachment.cgi
line 28.
> TBN= A=<DATA>J5</END>
> 
> The output IS INCORRECT

Hmm, I missed that -w -- we really should have use warnings in the source file.

By the way, how come that the warning message talks about attachment.cgi when
you run perl on test2.pl.
Comment 7 Jan Pazdziora 2008-03-03 04:27:15 EST
BTW, I've reproduced the problem on 5.8.5 and also on perl-5.8.0-88.7 in RHEL 3.
Comment 8 Need Real Name 2008-03-03 10:37:22 EST
>By the way, how come that the warning message talks about attachment.cgi when
you run perl on test2.pl.

It is copy/paste error of the first line. The file with the perl program is
attachment.cgi -
the one called "simplified test" attached to this report:
https://bugzilla.redhat.com/attachment.cgi?id=292362

The correct output, when I comment the line
# my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg;
and uncomment the lines
        my $x=$a;
        my($tmpbname)=$x=~m@<DATA>([^<>]*)@isg;
should be this:
#perl -w attachment.cgi 
TBN=J1 A=<DATA>J1</END>
TBN=J2 A=<DATA>J2</END>
TBN=J3 A=<DATA>J3</END>
TBN=J4 A=<DATA>J4</END>
TBN=J5 A=<DATA>J5</END>

The difference is the TBN= one of strings J1,J2,J3,J4,J5
while with the another code it produces
TBN= value of undef





Comment 9 Need Real Name 2008-03-13 09:09:57 EDT
same problem with perl-5.8.8-36.fc8
# rpm -q perl ; perl -w attachment.cgi
perl-5.8.8-36.fc8
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J1</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J2</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J3</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J4</END>
Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28.
TBN= A=<DATA>J5</END>
Comment 10 Tom "spot" Callaway 2008-03-13 09:26:47 EDT
FWIW, the test cases also fail on 5.10.0. We may want to file this upstream.
Comment 11 Marcela Mašláňová 2008-03-13 09:39:26 EDT
Already is: http://rt.perl.org/rt3/Public/Bug/Display.html?id=50072
Comment 12 Tom "spot" Callaway 2008-03-13 09:58:08 EDT
Indeed, when looking at that ticket, I agree with the assessment of the p5p
commenter, this "bug" is being caused by the /g.

Changing:

my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg;

to

my($tmpbname)=$a=~m@<DATA>([^<>]*)@is;

Resolves this issue. Closing as NOTABUG. If the original poster disagrees, I
suggest that it be directed at upstream, where the ticket is still open.
Comment 13 Need Real Name 2008-03-13 17:40:32 EDT
I just followed the link and read explanations.

What I can say.
For functions to have a side effect - this happens and sometimes unavoidable.
But for OPERATORS to have a side effect
is ugly and wrong.

But it may be too late to change in perl.
Comment 14 Yitzchak Scott-Thoennes 2008-03-16 20:56:00 EDT
Using /g in your scalar-context match in the if() explicitly requests the side
effect.  If you don't want it, don't do that then.

Note You need to log in before you can comment on or make changes to this bug.