public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/1190] New: fgetc()/fread() behaviour is not POSIX compliant
@ 2005-08-10 16:12 funtoos at yahoo dot com
  2005-08-10 16:15 ` [Bug libc/1190] " funtoos at yahoo dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: funtoos at yahoo dot com @ 2005-08-10 16:12 UTC (permalink / raw)
  To: glibc-bugs

A simple setup consisting of two programs. process A writes to fpA pointing to
file /a/b/c and process B reads from fpB pointing to file /a/b/c. Process B does
a select on fileno(fpB) for read readiness and does a fread() for 200 bytes.
This leads to 256 bytes read and EOF. Process A writes more data to fpA. Process
B again does a select(), followed by the fread(). (The select() calls don't wait
for timeout=250 msecs that they are supposed to wait because eof is still set
and select() rightly assumes that the fd is ready for read.) The second fread()
succeeds when the data actually becomes available as written by process A. The
second fread() should fail as per POSIX standard because the eof is still not
cleared by the app and an fgetc() (used by fread()), returns eof if eof is set
on the stream. This leads bad coding practices in linux and non-portable
programs. The above is a live example of how non-portable the NX free client
(called nxrun) became when app developer assumed that he could keep reading
without resetting the eof on the stream. Not only the program hangs on solaris,
but it sits in a tight loop because select() returns immediately on eof and the
wait of 250 ms is rendered redundant, on both linux and solaris. If fgetc() and
hence fread() had refused to read if stream has eof set like they are supposed
as per POSIX, the programmer would have caught his mistake on linux and not led
to hang on solaris and tight loop on linux.

Please refer the following for correct POSIX behaviour of fgetc()/fread():

http://www.opengroup.org/onlinepubs/009695399/functions/fgetc.html
http://www.opengroup.org/onlinepubs/009695399/functions/fread.html

-- 
           Summary: fgetc()/fread() behaviour is not POSIX compliant
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: critical
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: funtoos at yahoo dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sources.redhat.com/bugzilla/show_bug.cgi?id=1190

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/1190] fgetc()/fread() behaviour is not POSIX compliant
  2005-08-10 16:12 [Bug libc/1190] New: fgetc()/fread() behaviour is not POSIX compliant funtoos at yahoo dot com
@ 2005-08-10 16:15 ` funtoos at yahoo dot com
  2005-09-28  5:34 ` drepper at redhat dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: funtoos at yahoo dot com @ 2005-08-10 16:15 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From funtoos at yahoo dot com  2005-08-10 16:15 -------
sorry for 200/256 mess up. It should read 'process B does an fread() for 2000
bytes'. Also, processA wrote 256 bytes to begin the protocol.

-- 


http://sources.redhat.com/bugzilla/show_bug.cgi?id=1190

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/1190] fgetc()/fread() behaviour is not POSIX compliant
  2005-08-10 16:12 [Bug libc/1190] New: fgetc()/fread() behaviour is not POSIX compliant funtoos at yahoo dot com
  2005-08-10 16:15 ` [Bug libc/1190] " funtoos at yahoo dot com
@ 2005-09-28  5:34 ` drepper at redhat dot com
  2005-09-30 20:50 ` funtoos at yahoo dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: drepper at redhat dot com @ 2005-09-28  5:34 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2005-09-28 05:34 -------
I'm not going to spend a second on this until I see a small, self-contained
testcase.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


http://sourceware.org/bugzilla/show_bug.cgi?id=1190

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/1190] fgetc()/fread() behaviour is not POSIX compliant
  2005-08-10 16:12 [Bug libc/1190] New: fgetc()/fread() behaviour is not POSIX compliant funtoos at yahoo dot com
  2005-08-10 16:15 ` [Bug libc/1190] " funtoos at yahoo dot com
  2005-09-28  5:34 ` drepper at redhat dot com
@ 2005-09-30 20:50 ` funtoos at yahoo dot com
  2005-12-30 15:31 ` aj at suse dot de
  2007-02-18  4:39 ` drepper at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: funtoos at yahoo dot com @ 2005-09-30 20:50 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From funtoos at yahoo dot com  2005-09-30 20:50 -------
its a simple thing. fgetc() needs to return EOF if EOF is what the last call had
returned and is set on the stream, even though there is new data ready to be
read. EOF should be explicitly cleared (by the programmer) before the next call
to fgetc() is made by the programmer. This is a simple POSIX compliance
requirement as per the links I provided. What do we need a test case for? Are
you saying that the behaviour reported in the example is not the current
behaviour of glibc?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW


http://sourceware.org/bugzilla/show_bug.cgi?id=1190

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/1190] fgetc()/fread() behaviour is not POSIX compliant
  2005-08-10 16:12 [Bug libc/1190] New: fgetc()/fread() behaviour is not POSIX compliant funtoos at yahoo dot com
                   ` (2 preceding siblings ...)
  2005-09-30 20:50 ` funtoos at yahoo dot com
@ 2005-12-30 15:31 ` aj at suse dot de
  2007-02-18  4:39 ` drepper at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: aj at suse dot de @ 2005-12-30 15:31 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From aj at suse dot de  2005-12-30 15:31 -------
Please send a self-contained test program that shows the bug.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


http://sourceware.org/bugzilla/show_bug.cgi?id=1190

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/1190] fgetc()/fread() behaviour is not POSIX compliant
  2005-08-10 16:12 [Bug libc/1190] New: fgetc()/fread() behaviour is not POSIX compliant funtoos at yahoo dot com
                   ` (3 preceding siblings ...)
  2005-12-30 15:31 ` aj at suse dot de
@ 2007-02-18  4:39 ` drepper at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: drepper at redhat dot com @ 2007-02-18  4:39 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2007-02-18 04:39 -------
No test program provided in more than a year.  Closing.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |WORKSFORME


http://sourceware.org/bugzilla/show_bug.cgi?id=1190

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-02-18  4:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-10 16:12 [Bug libc/1190] New: fgetc()/fread() behaviour is not POSIX compliant funtoos at yahoo dot com
2005-08-10 16:15 ` [Bug libc/1190] " funtoos at yahoo dot com
2005-09-28  5:34 ` drepper at redhat dot com
2005-09-30 20:50 ` funtoos at yahoo dot com
2005-12-30 15:31 ` aj at suse dot de
2007-02-18  4:39 ` drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).