This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/5396: ifstream read()'s data multiple times on Solaris



>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<iostream>
#include<fstream>
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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]