public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21286] New: GNU extension stdio_filebuf problems when reading from pipe
@ 2005-04-29 15:54 ralfixx at gmx dot de
  2005-04-29 15:56 ` [Bug c++/21286] " ralfixx at gmx dot de
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: ralfixx at gmx dot de @ 2005-04-29 15:54 UTC (permalink / raw)
  To: gcc-bugs

Attach stdin (or any other FILE*) to an iostream via the rdbuf() created from a
FILE* by using the GNU extension stdio_filebuf() (see attached C++-File).

Input is just some big file with +11MB:

% wc -c big_file
11601584 big_file

This reads incorrect number of bytes when stdin is a pipe and using an block
size which is not some power of 2. The number of bytes read differs from run to run.
% cat big_file | ./t400 8687
total bytes read 9347072, blocks 1076
% cat big_file | ./t400 8687
total bytes read 978944, blocks 113
% cat big_file | ./t400 8687
total bytes read 8679424, blocks 1000
% cat big_file | ./t400 8687
total bytes read 3424256, blocks 395
% cat big_file | ./t400 8687
total bytes read 11601584, blocks 1336
% cat big_file | ./t400 2048
total bytes read 11601584, blocks 5665
% cat big_file | ./t400 2048
total bytes read 11601584, blocks 5665

No errors when stdin is redirected directly to the file.  

% ./t400 8676 < big_file
total bytes read 11601584, blocks 1338
% ./t400 8676 < big_file
total bytes read 11601584, blocks 1338
% ./t400 8676 < big_file
total bytes read 11601584, blocks 1338
% ./t400 8676 < big_file
total bytes read 11601584, blocks 1338

Also no problems when reading in 2048 or 4096 blocks:

% cat big_file | ./t400 2048
total bytes read 11601584, blocks 5665
% cat big_file | ./t400 2048
total bytes read 11601584, blocks 5665
% cat big_file | ./t400 2048
total bytes read 11601584, blocks 5665

% cat big_file | ./t400 4096
total bytes read 11601584, blocks 2833
% cat big_file | ./t400 4096
total bytes read 11601584, blocks 2833
% cat big_file | ./t400 4096
total bytes read 11601584, blocks 2833

Same problem on HP-UX 10.20 with gcc-4.0.0 (and 3.4.3 if it matters).

The same program runs w/o problems in gcc-3.4.1 and gcc-3.3.3 on the same platforms.

I actually had a shell loop trying block sizes from 1 to 10000 to find the
problematic ones, so if 8687 does not reproduce the bug, try the follwoing shell
loop:

i=8000
while test $i -lt 9000 ; do
  echo -e "$i: \\c"
  cat big_file | ./t400 $i
  i=`echo $i+1 | bc`
done


R'

-- 
           Summary: GNU extension stdio_filebuf problems when reading from
                    pipe
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ralfixx at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21286


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

end of thread, other threads:[~2005-07-18 18:40 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-29 15:54 [Bug c++/21286] New: GNU extension stdio_filebuf problems when reading from pipe ralfixx at gmx dot de
2005-04-29 15:56 ` [Bug c++/21286] " ralfixx at gmx dot de
2005-04-29 15:58 ` ralfixx at gmx dot de
2005-04-29 17:28 ` pcarlini at suse dot de
2005-04-29 21:31 ` [Bug libstdc++/21286] " pcarlini at suse dot de
2005-04-30  2:12 ` [Bug libstdc++/21286] [4.0/4.1 Regression] filebuf::xsgetn vs pipes ncm-nospam at cantrip dot org
2005-04-30  3:49 ` ncm-nospam at cantrip dot org
2005-04-30  6:54 ` cvs-commit at gcc dot gnu dot org
2005-04-30  8:00 ` pcarlini at suse dot de
2005-04-30 14:16 ` ralfixx at gmx dot de
2005-04-30 15:49 ` ncm-nospam at cantrip dot org
2005-04-30 22:56 ` cvs-commit at gcc dot gnu dot org
2005-04-30 22:57 ` pcarlini at suse dot de
2005-05-01 17:44 ` ralfixx at gmx dot de
2005-05-01 18:12 ` pcarlini at suse dot de
2005-05-01 19:12 ` ralfixx at gmx dot de
2005-05-01 19:28 ` pcarlini at suse dot de
2005-07-14 20:53 ` amu at alum dot mit dot edu
2005-07-14 23:58 ` pcarlini at suse dot de
2005-07-18 12:17 ` ralfixx at gmx dot de
2005-07-18 12:46 ` pcarlini at suse dot de
2005-07-18 15:02 ` ralfixx at gmx dot de
2005-07-18 17:08 ` pcarlini at suse dot de
2005-07-18 18:35 ` cvs-commit at gcc dot gnu dot org
2005-07-18 18:40 ` [Bug libstdc++/21286] [3.4/4.0/4.1 " pcarlini at suse dot de
2005-07-18 18:51 ` pcarlini at suse dot de

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).