Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fread() bug?



I’ve found what I consider to be a stream IO bug.  Here’s what’s happening:

 

  1. Open a file for writing (using fopen(…, “w”) ) and write some data to the file
  2. Flush the writer using fflush()
  3. Open a second stream to the file for reading only using fopen(…., “r”)
  4. Read some bytes using fseek() & fread() to confirm the reader can see the data written in step 1
  5. Have the writer update 1 byte using fwrite()
  6. Flush the writer using fflush()
  7. Using the read stream, read the byte written by the writer in step 5 using fseek() / fread()
  8. You will get the wrong answer here.  The read should return the byte written in step 5 but instead returns the old value written in step 1.

 

Is this is a bug?  Are there any work arounds? 

 

I wrote a simple test case to demonstrate this problem, which passes on Solaris.

 

Norm Green

 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.