[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#121642: marked as done (libstdc++3: Unable to do buffered cout (?))



Your message dated Thu, 30 May 2002 00:11:13 +0200
with message-id <15605.20993.28176.906482@gargle.gargle.HOWL>
and subject line bug closed upstream
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 29 Nov 2001 02:13:46 +0000
>From inaky@calliope1.fm.intel.com Wed Nov 28 20:13:45 2001
Return-path: <inaky@calliope1.fm.intel.com>
Received: from fmfdns01.fm.intel.com (calliope1.fm.intel.com) [132.233.247.10] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 169Ght-0004w5-00; Wed, 28 Nov 2001 20:13:45 -0600
Received: from fmsmsxvs041.fm.intel.com (fmsmsxvs041.fm.intel.com [132.233.42.126])
	by calliope1.fm.intel.com (8.9.1a+p1/8.9.1/d: relay.m4,v 1.46 2001/10/25 21:02:55 root Exp $) with SMTP id CAA24536
	for <submit@bugs.debian.org>; Thu, 29 Nov 2001 02:13:44 GMT
Received: (from milikk [10.10.213.18])
 by fmsmsxvs041.fm.intel.com (NAVGW 2.5.1.6) with SMTP id M2001112818145720575
 ; Wed, 28 Nov 2001 18:14:57 -0800
Received: from inaky by milikk with local (Exim 3.32 #1 (Debian))
	id 169GdE-0007BA-00; Wed, 28 Nov 2001 18:08:56 -0800
From: inaky.gonzalez@intel.com
Subject: libstdc++3: Unable to do buffered cout (?)
To: submit@bugs.debian.org
X-Mailer: bug 3.3.10
Message-Id: <E169GdE-0007BA-00@milikk>
Sender: Inaky Perez Gonzalez <inaky@calliope1.fm.intel.com>
Date: Wed, 28 Nov 2001 18:08:56 -0800
Delivered-To: submit@bugs.debian.org

Package: libstdc++3
Version: 1:3.0.2-3
Severity: normal

        Hi!

I have seen an strange behaviour of libstdc++ regarding buffering of
streams; I don't know if it is my fault or the libraries fault. It
basically writes character per character whenever I do a cout <<
"something". 

Given the following program:

#include <iostream>
using namespace std;

int main (void)
{
  cout << "Hello world!" << endl;
  return 0;
}

compiled it with gcc-2.95 and gcc-3.0 (ok, g++ actually). When
compiled with gcc-2.95 and run with strace(1), I get the following:

$ g++-2.95 -Wall -O2 testout.cc -o testout
$ ./testout
Hello world!
$ strace ./testout > /dev/null
execve("./testout", ["./testout"], [/* 28 vars */]) = 0
uname({sys="Linux", node="milikk", ...}) = 0
brk(0)                                  = 0x8049834
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=66967, ...}) = 0
old_mmap(NULL, 66967, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40016000
close(3)                                = 0
open("/usr/lib/libstdc++-libc6.2-2.so.3", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`\251\1"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0644, st_size=291720, ...}) = 0
old_mmap(NULL, 303748, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40027000
mprotect(0x4005e000, 78468, PROT_NONE)  = 0
old_mmap(0x4005e000, 69632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x36000) = 0x4005e000
old_mmap(0x4006f000, 8836, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4006f000
close(3)                                = 0
open("/lib/libm.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 I\0\000"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0644, st_size=134668, ...}) = 0
old_mmap(NULL, 137220, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40072000
mprotect(0x40093000, 2052, PROT_NONE)   = 0
old_mmap(0x40093000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x20000) = 0x40093000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0(\327\1"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1171196, ...}) = 0
old_mmap(NULL, 1187968, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40094000
mprotect(0x401ac000, 41088, PROT_NONE)  = 0
old_mmap(0x401ac000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x117000) = 0x401ac000
old_mmap(0x401b2000, 16512, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x401b2000
close(3)                                = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x401b7000
munmap(0x40016000, 66967)               = 0
fstat64(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE, 0xbffff718) = -1 ENOTTY (Inappropriate ioctl for device)
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40016000
write(1, "Hello world!\n", 13)          = 13
_exit(0)                                = ?


Note the previous-to-last line, write(1, "Hello world!\n", 13), that
is, a buffered write, as expected. However, now let's do the same with
3.0:

$ g++-3.0 -Wall -O2 testout.cc -o testout
$ ./testout
Hello world!
$ strace ./testout > /dev/null
execve("./testout", ["./testout"], [/* 28 vars */]) = 0
uname({sys="Linux", node="milikk", ...}) = 0
brk(0)                                  = 0x804c890
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=66967, ...}) = 0
old_mmap(NULL, 66967, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40016000
close(3)                                = 0
open("/usr/lib/libstdc++.so.3", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260\255"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0644, st_size=565536, ...}) = 0
old_mmap(NULL, 587464, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40027000
mprotect(0x4009e000, 100040, PROT_NONE) = 0
old_mmap(0x4009e000, 81920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x76000) = 0x4009e000
old_mmap(0x400b2000, 18120, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x400b2000
close(3)                                = 0
open("/lib/libm.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 I\0\000"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0644, st_size=134668, ...}) = 0
old_mmap(NULL, 137220, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x400b7000
mprotect(0x400d8000, 2052, PROT_NONE)   = 0
old_mmap(0x400d8000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x20000) = 0x400d8000
close(3)                                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\330\22"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0644, st_size=27180, ...}) = 0
old_mmap(NULL, 30220, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x400d9000
mprotect(0x400df000, 5644, PROT_NONE)   = 0
old_mmap(0x400df000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x5000) = 0x400df000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0(\327\1"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1171196, ...}) = 0
old_mmap(NULL, 1187968, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x400e1000
mprotect(0x401f9000, 41088, PROT_NONE)  = 0
old_mmap(0x401f9000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x117000) = 0x401f9000
old_mmap(0x401ff000, 16512, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x401ff000
close(3)                                = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40204000
munmap(0x40016000, 66967)               = 0
brk(0)                                  = 0x804c890
brk(0x804c8c8)                          = 0x804c8c8
brk(0x804d000)                          = 0x804d000
brk(0x804e000)                          = 0x804e000
fstat64(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE, 0xbffff654) = -1 ENOTTY (Inappropriate ioctl for device)
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40016000
write(1, "H", 1)                        = 1
write(1, "e", 1)                        = 1
write(1, "l", 1)                        = 1
write(1, "l", 1)                        = 1
write(1, "o", 1)                        = 1
write(1, " ", 1)                        = 1
write(1, "w", 1)                        = 1
write(1, "o", 1)                        = 1
write(1, "r", 1)                        = 1
write(1, "l", 1)                        = 1
write(1, "d", 1)                        = 1
write(1, "!", 1)                        = 1
write(1, "\n", 1)                       = 1
munmap(0x40016000, 4096)                = 0
_exit(0)                                = ?

And puf! there you have it, unbuffered, one char at a time, super
innefective writes.

I tried to investigate and found nothing. I was thinking maybe
there is a switch for it or something, but found none. Anyway, by
default, the output should be buffered, AFAIK ... and unless I am
missing anything.

Any clues?

Thanks!!!

-- System Information
Debian Release: testing/unstable
Kernel Version: Linux milikk 2.4.10.2-milikk #1 SMP mar oct 30 15:30:23 PST 2001 i686 unknown

Versions of the packages libstdc++3 depends on:
ii  gcc-3.0-base   3.0.2-3        The GNU Compiler Collection (base package).
ii  libc6          2.2.4-6        GNU C Library: Shared libraries and Timezone
ii  libgcc1        3.0.2-3        GCC support library.



---------------------------------------
Received: (at 121642-done) by bugs.debian.org; 29 May 2002 22:15:09 +0000
>From doko@cs.tu-berlin.de Wed May 29 17:15:09 2002
Return-path: <doko@cs.tu-berlin.de>
Received: from mail.cs.tu-berlin.de [130.149.17.13] (root)
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 17DBim-0005X4-00; Wed, 29 May 2002 17:15:08 -0500
Received: from bolero.cs.tu-berlin.de (daemon@bolero.cs.tu-berlin.de [130.149.19.1])
	by mail.cs.tu-berlin.de (8.9.3/8.9.3) with ESMTP id AAA03536
	for <121642-done@bugs.debian.org>; Thu, 30 May 2002 00:11:13 +0200 (MET DST)
Received: (from doko@localhost)
	by bolero.cs.tu-berlin.de (8.11.6+Sun/8.9.3) id g4TMBDh17835;
	Thu, 30 May 2002 00:11:13 +0200 (MEST)
From: Matthias Klose <doko@cs.tu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <15605.20993.28176.906482@gargle.gargle.HOWL>
Date: Thu, 30 May 2002 00:11:13 +0200
To: 121642-done@bugs.debian.org
Subject: bug closed upstream
X-Mailer: VM 7.03 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid
Delivered-To: 121642-done@bugs.debian.org

See http://gcc.gnu.org/cgi-bin/gnatsweb.pl (problem report 3269).

and http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#8


-- 
To UNSUBSCRIBE, email to debian-gcc-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: