Bug 49104 - Buffered I/O calls not thread safe on multiprocessor systems
Buffered I/O calls not thread safe on multiprocessor systems
Status: CLOSED WORKSFORME
Product: Red Hat Linux
Classification: Retired
Component: libc (Show other bugs)
6.2
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-07-13 14:50 EDT by Jason Coleman
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-07-13 15:05:18 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)
Sample code to reproduce problem (3.10 KB, text/plain)
2001-07-13 15:03 EDT, Jason Coleman
no flags Details
Sample code of working version using non-buffered calls (3.25 KB, text/plain)
2001-07-13 15:05 EDT, Jason Coleman
no flags Details

  None (edit)
Description Jason Coleman 2001-07-13 14:50:38 EDT
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 15:03:51 EDT
Created attachment 23547 [details]
Sample code to reproduce problem
Comment 2 Jason Coleman 2001-07-13 15:05:14 EDT
Created attachment 23548 [details]
Sample code of working version using non-buffered calls
Comment 3 Jakub Jelinek 2001-07-20 09:05:16 EDT
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.