Bug 49104 - Buffered I/O calls not thread safe on multiprocessor systems
Summary: Buffered I/O calls not thread safe on multiprocessor systems
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libc
Version: 6.2
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-07-13 18:50 UTC by Jason Coleman
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-07-13 19:05:18 UTC
Embargoed:


Attachments (Terms of Use)
Sample code to reproduce problem (3.10 KB, text/plain)
2001-07-13 19:03 UTC, Jason Coleman
no flags Details
Sample code of working version using non-buffered calls (3.25 KB, text/plain)
2001-07-13 19:05 UTC, Jason Coleman
no flags Details

Description Jason Coleman 2001-07-13 18:50:38 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)

Description of problem:
When using buffered I/O calls (fopen, fread, fwrite, fclose) to read and 
write files from multithreaded programs, data corruption occurs when run 
on multiprocessor machine. The same program using non-buffered calls 
(open, close, read, write) works fine.

How reproducible:
Always

Steps to Reproduce:
1. Build attached freadtest.cpp program using "g++ freadtest.cpp -o 
freadtest -lpthread"
2. Run freadtest
3. Build readtest.cpp program using "g++ readtest.cpp -o readtest -
lpthread" to see working version using non-buffered calls
	

Actual Results:  In the buffered I/O version, around 3-5% of the time the 
data gets corrupted.

Expected Results:  In the non-buffered I/O version, the data is never 
corrupted.

Additional info:

Comment 1 Jason Coleman 2001-07-13 19:03:51 UTC
Created attachment 23547 [details]
Sample code to reproduce problem

Comment 2 Jason Coleman 2001-07-13 19:05:14 UTC
Created attachment 23548 [details]
Sample code of working version using non-buffered calls

Comment 3 Jakub Jelinek 2001-07-20 13:05:16 UTC
Cannot reproduce this (2way PIII). I was running /bin/true loop with this
for several hours without getting any corruption.


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