• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
fread() bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fread() bug?


  • Subject: fread() bug?
  • From: Norm Green <email@hidden>
  • Date: Sat, 5 Jan 2008 08:29:16 -0800

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: fread() bug?
      • From: Steve Checkoway <email@hidden>
  • Prev by Date: Re: ECX_BAD_ACCESS again
  • Next by Date: Posix Timers?
  • Previous by thread: Re: ECX_BAD_ACCESS again
  • Next by thread: Re: fread() bug?
  • Index(es):
    • Date
    • Thread