From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22557 invoked by alias); 15 Jan 2002 23:06:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 22525 invoked by uid 71); 15 Jan 2002 23:06:01 -0000 Resent-Date: 15 Jan 2002 23:06:01 -0000 Resent-Message-ID: <20020115230601.22524.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, anderson@ligo.caltech.edu Received:(qmail 18918 invoked by uid 61); 15 Jan 2002 22:56:17 -0000 Message-Id:<20020115225617.18917.qmail@sources.redhat.com> Date: Tue, 15 Jan 2002 15:06:00 -0000 From: anderson@ligo.caltech.edu Reply-To: anderson@ligo.caltech.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/5396: ifstream read()'s data multiple times on Solaris X-SW-Source: 2002-01/txt/msg00575.txt.bz2 List-Id: >Number: 5396 >Category: libstdc++ >Synopsis: ifstream read()'s data multiple times on Solaris >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Jan 15 15:06:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Stuart Anderson >Release: gcc-3.0.3 >Organization: >Environment: SunOS XXX 5.8 Generic_108528-12 sun4u sparc SUNW,Ultra-60 >Description: The following simple code to read a file using ifstream results in the following system call chain on Solaris 8 with gcc-3.0.x, read(8k) lseek(1k absolute) read(8k) lseek(2k absolute) ... rather than the following from gcc-2.95.3, read(8k) read(8k) read(8k) ... Note in the gcc-3.0.x case there are 8 times more calls to read() than for gcc-2.95.3! This bug does not occur on a RedHat7.2 machine with gcc-3.0.3, and has been reproduced on Solaris with gcc-3.0.1, 3.0.2, and 3.0.3. The resulting performance hit prevents our project from using gcc-3.0.x. >How-To-Repeat: truss ./a.out /dev/zero after compiling, #include #include main(int argc, char *argv[]){ std::cerr << "foo" << std::endl; std::ifstream in(argv[1]); for(int i = 0; i < 100; i++){ char data[1024]; in.read(data,1024); } } Here is a section of the truss output that shows the problem: open("/dev/zero", O_RDONLY) = 3 fstat64(3, 0xFFBEF2E0) = 0 brk(0x00033140) = 0 brk(0x00035140) = 0 ioctl(3, TCGETA, 0xFFBEF26C) Err#6 ENXIO read(3, "\0\0\0\0\0\0\0\0\0\0\0\0".., 8192) = 8192 lseek(3, 0xFFFFE000, SEEK_CUR) = 0 llseek(3, 0, SEEK_CUR) = 0 lseek(3, 1024, SEEK_CUR) = 1024 llseek(3, 0, SEEK_CUR) = 1024 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0".., 8192) = 8192 lseek(3, 0xFFFFE000, SEEK_CUR) = 1024 llseek(3, 0, SEEK_CUR) = 1024 lseek(3, 1024, SEEK_CUR) = 2048 llseek(3, 0, SEEK_CUR) = 2048 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0".., 8192) = 8192 lseek(3, 0xFFFFE000, SEEK_CUR) = 2048 llseek(3, 0, SEEK_CUR) = 2048 lseek(3, 1024, SEEK_CUR) = 3072 llseek(3, 0, SEEK_CUR) = 3072 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0".., 8192) = 8192 >Fix: >Release-Note: >Audit-Trail: >Unformatted: