Bug 157052 - read from shared file descriptor undeterministic
read from shared file descriptor undeterministic
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
4
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Kernel Maintainer List
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-05-06 10:23 EDT by Jan Christiaan van Winkel
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-05-08 15:07:56 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)
the program that shows the bug (495 bytes, text/plain)
2005-05-06 10:24 EDT, Jan Christiaan van Winkel
no flags Details

  None (edit)
Description Jan Christiaan van Winkel 2005-05-06 10:23:14 EDT
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):
kernel-2.6.11-1.1226_FC4

How reproducible:
Always

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/libc.so.6
1505808 bytes read by me .....
1505808 bytes read by me .....
[jc@oreo ~]$ ./bug < /lib/libc.so.6
1505808 bytes read by me .....
0 bytes read by me .....
[jc@oreo ~]$ ./bug < /lib/libc.so.6
1505808 bytes read by me .....
0 bytes read by me .....
[jc@oreo ~]$ ./bug < /lib/libc.so.6
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 10:24:34 EDT
Created attachment 114081 [details]
the program that shows the bug
Comment 2 Pete Zaitcev 2005-05-08 15:07:56 EDT
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 15:09:39 EDT
> 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".

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