Bug 107904 - read from shared file descriptor undeterministic
Summary: read from shared file descriptor undeterministic
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: kernel
Version: 9
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Arjan van de Ven
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-10-24 10:22 UTC by Jan Christiaan van Winkel
Modified: 2007-04-18 16:58 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-09-30 15:41:39 UTC
Embargoed:


Attachments (Terms of Use)
the source of the program displaying the problem (472 bytes, text/plain)
2003-10-24 10:24 UTC, Jan Christiaan van Winkel
no flags Details

Description Jan Christiaan van Winkel 2003-10-24 10:22:23 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920
Netscape/7.0

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:
Always

Steps to Reproduce:
$ make countem
$ ls -l severn-i386-disc1.iso
$ ./countem < severn-i386-disc1.iso  # a file that does not fit in cache 
$ ./countem < severn-i386-disc1.iso  # a file that does not fit in cache 
$ ./countem < severn-i386-disc1.iso  # a file that does not fit in cache 
$ ./countem < severn-i386-disc1.iso  # a file that does not fit in cache 

For a smaller file:
$ ls -lL /boot/vmlinuz
$ ./countem <  /lib/libdb-4.0.so    # a file that fits in cache
$ ./countem <  /lib/libdb-4.0.so    # a file that fits in cache
$ ./countem <  /lib/libdb-4.0.so    # a file that fits in cache
$ ./countem <  /lib/libdb-4.0.so    # a file that fits in cache


Actual Results:  [jc@minioreo FEDORA]$ ls -l severn-i386-disc1.iso 
-rw-r--r--    1 jc       jc       666861568 Oct 13 10:52 severn-i386-disc1.iso
[jc@minioreo FEDORA]$ ../../countem <  severn-i386-disc1.iso
665537536 bytes read by me .....
664830976 bytes read by me .....
[jc@minioreo FEDORA]$ ../../countem <  severn-i386-disc1.iso
666671104 bytes read by me .....
664156160 bytes read by me .....
[jc@minioreo FEDORA]$ ../../countem <  severn-i386-disc1.iso
660071424 bytes read by me .....
664846336 bytes read by me .....
[jc@minioreo FEDORA]$ ../../countem <  severn-i386-disc1.iso
664833024 bytes read by me .....
664593408 bytes read by me .....

[jc@minioreo jc]$ ls -l /lib/libdb-4.0.so 
-r-xr-xr-x    2 root     root      5512945 Feb  5  2003 /lib/libdb-4.0.so
[jc@minioreo jc]$ ./countem < /lib/libdb-4.0.so  #first run gives bad numbers
5512945 bytes read by me .....
5402353 bytes read by me .....
[jc@minioreo jc]$ ./countem < /lib/libdb-4.0.so #subsequent runs OK
3982065 bytes read by me .....
1530880 bytes read by me .....
[jc@minioreo jc]$ ./countem < /lib/libdb-4.0.so
207601 bytes read by me .....
5305344 bytes read by me .....
[jc@minioreo jc]$ ./countem < /lib/libdb-4.0.so
5512945 bytes read by me .....
0 bytes read by me .....


Expected Results:  The sum of bytes read by the two processes should always be
the same, i.e. the size of the file.  The two child processes share the file
handle, and thus the R/W pointer.  Appearantly, if one of the processes does a
read, the R/W pointer is not updated at the moment the other process issues the
read, if the read comes from disk (and not from the cache)

Additional info:

Comment 1 Jan Christiaan van Winkel 2003-10-24 10:24:25 UTC
Created attachment 95455 [details]
the source of the program displaying the problem

compile this program as shown in the description field and feed the program
some data on standard input

Comment 2 Bugzilla owner 2004-09-30 15:41:39 UTC
Thanks for the bug report. However, Red Hat no longer maintains this version of
the product. Please upgrade to the latest version and open a new bug if the problem
persists.

The Fedora Legacy project (http://fedoralegacy.org/) maintains some older releases, 
and if you believe this bug is interesting to them, please report the problem in
the bug tracker at: http://bugzilla.fedora.us/



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