Bug 185623

Summary: tell doesn't return right value when appending
Product: Red Hat Enterprise Linux 3 Reporter: Bastien Nocera <bnocera>
Component: perlAssignee: Jason Vas Dias <jvdias>
Status: CLOSED ERRATA QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: prockai
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2006-0294 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-05-10 21:57:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 187539    
Attachments:
Description Flags
perl-5.8.0-perlio-tell-bug-fix.patch
none
Patch which fixes issue in perl-5.8.0-90.9 none

Description Bastien Nocera 2006-03-16 14:10:30 UTC
perl-5.8.0-90.4

The following test program returns the wrong value with RHEL3's Perl:
---8<---
#!/usr/bin/perl

open(F, ">>somefile");

$a=tell(F);
print "$a\n";

print F "end";

$a=tell(F);
print "$a\n";

close(F);
---8<---

On RHEL3:
# rm -f somefile
# perl foo.pl
0
3
# perl foo.pl
0
3
# perl foo.pl
0
3

On RHEL4:
# perl foo.pl
0
3
# perl foo.pl
3
6


Upstream bug seemed to be:
http://guest:guest@rt.perl.org/rt2//Ticket/Display.html?id=18711
With the patch at:
http://public.activestate.com/cgi-bin/perlbrowse?patch=18471

Comment 1 Bastien Nocera 2006-03-16 14:12:27 UTC
Created attachment 126221 [details]
perl-5.8.0-perlio-tell-bug-fix.patch

Rediff'ed patch from the upstream fix. It isn't enough to fix the bug though,
as the first tell after an open() is still broken:
# perl foo.pl
0
3
# perl foo.pl
0
6

Comment 2 Bastien Nocera 2006-03-16 14:15:27 UTC
I compared the code for flush, open and tell in the the current HEAD:
http://public.activestate.com/cgi-bin/perlbrowse?file=perlio.c&rev=
and with the patched version and couldn't find any significant differences to
explain why it didn't fix it.

Comment 3 Jason Vas Dias 2006-03-16 18:50:02 UTC
Created attachment 126240 [details]
Patch which fixes issue in perl-5.8.0-90.9

Here's a patch which fixes the issue, which I'm applying in perl-5.8.0-90.9 .

The PerlIOUnix_open function also needed to lseek(fd,0,SEEK_END) if the file
was opened in append mode - this was fixed with a previous upstream patch.

Comment 4 Jason Vas Dias 2006-03-16 20:29:10 UTC
Now fixed with perl-5.8.0-90.9, available from:
   http://people.redhat.com/~jvdias/perl/RHEL-3 


Comment 13 Red Hat Bugzilla 2006-05-10 21:57:10 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2006-0294.html