Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 157052

Summary: read from shared file descriptor undeterministic
Product: [Fedora] Fedora Reporter: Jan Christiaan van Winkel <jc>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 4CC: wtogami
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-05-08 19:07:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Description Flags
the program that shows the bug none

Description Jan Christiaan van Winkel 2005-05-06 14:23:14 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3

Description of problem:
If a process forks twice and both child processes read from the same file
descriptor, the total number of bytes read by these two processes will differ
for each run if the file read does not fit in the cache.
Attached you find the source for the program that displays the problem.
If the file read is small enough, the sum of bytes read is correct, except for
the first run.  If the file is too large to fit in the cache, the result is
always wrong.

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

How reproducible:

Steps to Reproduce:
1. make testprog
2. testprog < BIGFILE
3. testprog < BIGFILE

Actual Results:  # for a big file:
[jc@oreo ~]$ ./bug < /over/FC3/FC3-i386-disc1.iso
362714112 bytes read by me .....
382346240 bytes read by me .....
[jc@oreo ~]$ ./bug < /over/FC3/FC3-i386-disc2.iso
668017664 bytes read by me .....
667849728 bytes read by me .....
[jc@oreo ~]$ ./bug < /over/FC3/FC3-i386-disc2.iso
631341056 bytes read by me .....
627876864 bytes read by me .....
[jc@oreo ~]$ ./bug < /over/FC3/FC3-i386-disc2.iso
349428736 bytes read by me .....
459860992 bytes read by me .....
[jc@oreo ~]$ ./bug < /over/FC3/FC3-i386-disc2.iso
668520448 bytes read by me .....
55504896 bytes read by me .....

# for a smaller file:
jc@oreo ~]$ ./bug < /lib/
1505808 bytes read by me .....
1505808 bytes read by me .....
[jc@oreo ~]$ ./bug < /lib/
1505808 bytes read by me .....
0 bytes read by me .....
[jc@oreo ~]$ ./bug < /lib/
1505808 bytes read by me .....
0 bytes read by me .....
[jc@oreo ~]$ ./bug < /lib/
1505808 bytes read by me .....
0 bytes read by me .....

Expected Results:  The sum of the two readers in every run should be a constant, i.e. the size of the file.

Additional info:

This bug is not only present in FC4t2, but also in FC2, FC3, on both i386 and x86-64

Comment 1 Jan Christiaan van Winkel 2005-05-06 14:24:34 UTC
Created attachment 114081 [details]
the program that shows the bug

Comment 2 Pete Zaitcev 2005-05-08 19:07:56 UTC
This is not specific to Fedora and is not a regression. Linux kernel
2.4 does the same.

In case of writes to a shared log file, O_APPEND has to be used.

Comment 3 Pete Zaitcev 2005-05-08 19:09:39 UTC
> In case of writes to a shared log file, O_APPEND has to be used.
What I meant to say was "but in case of reads, application has to
serialize access".