From owner-freebsd-bugs@FreeBSD.ORG Fri Jan 19 14:30:18 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DB7A316A40A for ; Fri, 19 Jan 2007 14:30:18 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id A3EB913C442 for ; Fri, 19 Jan 2007 14:30:18 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l0JEUIPg051106 for ; Fri, 19 Jan 2007 14:30:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l0JEUIL6051104; Fri, 19 Jan 2007 14:30:18 GMT (envelope-from gnats) Resent-Date: Fri, 19 Jan 2007 14:30:18 GMT Resent-Message-Id: <200701191430.l0JEUIL6051104@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Trenton Schulz Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 11FFA16A400 for ; Fri, 19 Jan 2007 14:25:54 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 03A7413C442 for ; Fri, 19 Jan 2007 14:25:54 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l0JEPrw2072788 for ; Fri, 19 Jan 2007 14:25:53 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l0JEPr1Z072787; Fri, 19 Jan 2007 14:25:53 GMT (envelope-from nobody) Message-Id: <200701191425.l0JEPr1Z072787@www.freebsd.org> Date: Fri, 19 Jan 2007 14:25:53 GMT From: Trenton Schulz To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: misc/108118: Files cache their eof status X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jan 2007 14:30:18 -0000 >Number: 108118 >Category: misc >Synopsis: Files cache their eof status >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jan 19 14:30:17 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Trenton Schulz >Release: FreeBSD 6.0 (reproduced on 6.2-RC as well) >Organization: Trolltech ASA >Environment: FreeBSD stimpy.troll.no 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Wed Dec 7 09:49:59 CET 2005 root@stimpy.troll.no:/usr/obj/usr/src/sys/SMP i386 >Description: When opening one file handle for reading binary and another for writing binary, one can write a byte, flush the file, and then attempt to read two bytes, the function will fail to read the one byte. This does not happen on HP-UX, AIX, or Linux >How-To-Repeat: #include #include int main() { FILE *writeFile; FILE *readFile; char readChar; int i; writeFile = fopen("/tmp/fooFile", "wb"); readFile = fopen("/tmp/fooFile", "rb"); for (i = 0; i < 2; i++) { fwrite("a", 1, 1, writeFile); fflush(writeFile); assert(fread(&readChar, 1, 2, readFile) > 0); } return 0; } >Fix: The programmer can call fseek() and try again. But it's a bit of second guessing. I guess it shouldn't cache the eof check. >Release-Note: >Audit-Trail: >Unformatted: