public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff
@ 2006-03-21 12:28 sam at quux dot dropbear dot id dot au
2006-03-21 12:29 ` [Bug libstdc++/26777] " sam at quux dot dropbear dot id dot au
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: sam at quux dot dropbear dot id dot au @ 2006-03-21 12:28 UTC (permalink / raw)
To: gcc-bugs
The following code demonstrates the bug.
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
streambuf *s=cin.rdbuf();
int c=s->sgetc();
s->pubseekoff(0,ios::cur,ios::in);
cout << s;
}
When the resulting executable is run with standard input coming
(for example) a pipe, the first 8191 bytes of input are not
replicated to standard out.
Expected behaviour is for pubseekoff to fail, but not to throw
away buffered data in the process.
If sync_with_stdio(false) is not called, the program behaves
as expected.
If sgetc() is not called on the streambuf, the program behaves
as expected.
If standard input is redirected from a file, then pubseekoff
does not fail, and the output is as expected.
Compiler output and a demonstration:
$ g++ -v --save-temps -o bug bug.cc
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.0.2-r3/work/gcc-4.0.2/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.0.2
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.0.2
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.0.2/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.0.2/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib --disable-checking
--disable-werror --disable-libunwind-exceptions --enable-multilib
--disable-libmudflap --disable-libgcj --enable-languages=c,c++,f95
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu
Thread model: posix
gcc version 4.0.2 (Gentoo 4.0.2-r3, pie-8.7.8)
/usr/libexec/gcc/x86_64-pc-linux-gnu/4.0.2/cc1plus -E -quiet -v -D_GNU_SOURCE
bug.cc -mtune=k8 -fpch-preprocess -o bug.ii
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/include/g++-v4
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/include/g++-v4/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/include/g++-v4/backward
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/include
/usr/include
End of search list.
/usr/libexec/gcc/x86_64-pc-linux-gnu/4.0.2/cc1plus -fpreprocessed bug.ii
-quiet -dumpbase bug.cc -mtune=k8 -auxbase bug -version -o bug.s
GNU C++ version 4.0.2 (Gentoo 4.0.2-r3, pie-8.7.8) (x86_64-pc-linux-gnu)
compiled by GNU C version 4.0.2 (Gentoo 4.0.2-r3, pie-8.7.8).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/../../../../x86_64-pc-linux-gnu/bin/as
-V -Qy -o bug.o bug.s
GNU assembler version 2.16.1 (x86_64-pc-linux-gnu) using BFD version 2.16.1
/usr/libexec/gcc/x86_64-pc-linux-gnu/4.0.2/collect2 --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o bug
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/../../../../lib64/crt1.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/crtbegin.o
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/../../../../x86_64-pc-linux-gnu/lib
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/../../../../lib64
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/../../.. -L/lib/../lib64
-L/usr/lib/../lib64 bug.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/crtend.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.2/../../../../lib64/crtn.o
$ dd if=/dev/urandom bs=16k count=1 of=test-in
1+0 records in
1+0 records out
$ dd if=test-in bs=1 skip=8191 of=test-trunc
8193+0 records in
8193+0 records out
$ cat test-in | ./bug > test-out
$ cmp test-out test-trunc
$ wc -c test-in test-out test-trunc
16384 test-in
8193 test-out
8193 test-trunc
32770 total
$
--
Summary: sync_with_stdio(false) triggers bug with sgetc and
pubseekoff
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sam at quux dot dropbear dot id dot au
GCC build triplet: x86_64-pc-linux-gnu
GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
@ 2006-03-21 12:29 ` sam at quux dot dropbear dot id dot au
2006-03-21 14:21 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sam at quux dot dropbear dot id dot au @ 2006-03-21 12:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from sam at quux dot dropbear dot id dot au 2006-03-21 12:29 -------
Created an attachment (id=11081)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11081&action=view)
--save-temps output from compilation of example code
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
2006-03-21 12:29 ` [Bug libstdc++/26777] " sam at quux dot dropbear dot id dot au
@ 2006-03-21 14:21 ` pinskia at gcc dot gnu dot org
2006-03-21 14:59 ` sam at quux dot dropbear dot id dot au
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-21 14:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-03-21 14:21 -------
GNU C++ version 4.0.2 (Gentoo 4.0.2-r3, pie-8.7.8) (x86_64-pc-linux-gnu)
compiled by GNU C version 4.0.2 (Gentoo 4.0.2-r3, pie-8.7.8).
This really should have been reported to gentoo first.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
2006-03-21 12:29 ` [Bug libstdc++/26777] " sam at quux dot dropbear dot id dot au
2006-03-21 14:21 ` pinskia at gcc dot gnu dot org
@ 2006-03-21 14:59 ` sam at quux dot dropbear dot id dot au
2006-03-21 23:15 ` pcarlini at suse dot de
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sam at quux dot dropbear dot id dot au @ 2006-03-21 14:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from sam at quux dot dropbear dot id dot au 2006-03-21 14:59 -------
Sorry - I should have confirmed it on at least one other platform before
submitting.
So I've done so now!
Exactly the same behaviour occurs on a i386-redhat-linux host with gcc version
4.0.0 20050519 (Red Hat 4.0.0-8).
Also confirmed on x86_64-pc-linux-gnu with an earlier version of gcc under
Gentoo, gcc version 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8).
I'd like to try it against a clean install of the latest stable gcc and libc
versions, but unfortunately right now I do not have the time to set this up,
nor to run through the actual libstdc++ source and see if I can spot what is
going on. That the same buggy behaviour is exhibited on two different linux
platforms, and across a series of gcc versions from 3.4.4 to 4.0.2, does point
towards it being an actual libstdc++ bug though I think.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
` (2 preceding siblings ...)
2006-03-21 14:59 ` sam at quux dot dropbear dot id dot au
@ 2006-03-21 23:15 ` pcarlini at suse dot de
2006-03-22 15:14 ` paolo at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-03-21 23:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pcarlini at suse dot de 2006-03-21 23:15 -------
Yes, I think we can fix this rathe easily in basic_filebuf<>::_M_seek, by
checking the return value of _M_file.seekoff. Working on it... Thanks for your
report.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pcarlini at suse dot de
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-03-21 23:15:29
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
` (3 preceding siblings ...)
2006-03-21 23:15 ` pcarlini at suse dot de
@ 2006-03-22 15:14 ` paolo at gcc dot gnu dot org
2006-03-22 15:15 ` pcarlini at suse dot de
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-03-22 15:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from paolo at gcc dot gnu dot org 2006-03-22 15:13 -------
Subject: Bug 26777
Author: paolo
Date: Wed Mar 22 15:13:46 2006
New Revision: 112286
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112286
Log:
2006-03-22 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/26777
* include/bits/fstream.tcc (basic_filebuf<>::_M_seek): Check
the return value of _M_file.seekoff.
* testsuite/27_io/basic_filebuf/seekoff/char/26777.cc: New.
Added:
trunk/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/26777.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/fstream.tcc
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
` (4 preceding siblings ...)
2006-03-22 15:14 ` paolo at gcc dot gnu dot org
@ 2006-03-22 15:15 ` pcarlini at suse dot de
2006-03-28 21:58 ` pcarlini at suse dot de
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-03-22 15:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pcarlini at suse dot de 2006-03-22 15:15 -------
Fixed for 4.2.0.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
` (5 preceding siblings ...)
2006-03-22 15:15 ` pcarlini at suse dot de
@ 2006-03-28 21:58 ` pcarlini at suse dot de
2006-03-28 21:58 ` pcarlini at suse dot de
2006-03-29 0:12 ` paolo at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-03-28 21:58 UTC (permalink / raw)
To: gcc-bugs
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.2.0 |4.1.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
` (6 preceding siblings ...)
2006-03-28 21:58 ` pcarlini at suse dot de
@ 2006-03-28 21:58 ` pcarlini at suse dot de
2006-03-29 0:12 ` paolo at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-03-28 21:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pcarlini at suse dot de 2006-03-28 21:58 -------
*** Bug 26907 has been marked as a duplicate of this bug. ***
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |trumsko at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26777] sync_with_stdio(false) triggers bug with sgetc and pubseekoff
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
` (7 preceding siblings ...)
2006-03-28 21:58 ` pcarlini at suse dot de
@ 2006-03-29 0:12 ` paolo at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-03-29 0:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from paolo at gcc dot gnu dot org 2006-03-29 00:12 -------
Subject: Bug 26777
Author: paolo
Date: Wed Mar 29 00:12:21 2006
New Revision: 112477
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112477
Log:
2006-03-28 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/26777
* include/bits/fstream.tcc (basic_filebuf<>::_M_seek): Check
the return value of _M_file.seekoff.
* testsuite/27_io/basic_filebuf/seekoff/char/26777.cc: New.
Added:
branches/gcc-4_1-branch/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/26777.cc
Modified:
branches/gcc-4_1-branch/libstdc++-v3/ChangeLog
branches/gcc-4_1-branch/libstdc++-v3/include/bits/fstream.tcc
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26777
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-03-29 0:12 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-21 12:28 [Bug libstdc++/26777] New: sync_with_stdio(false) triggers bug with sgetc and pubseekoff sam at quux dot dropbear dot id dot au
2006-03-21 12:29 ` [Bug libstdc++/26777] " sam at quux dot dropbear dot id dot au
2006-03-21 14:21 ` pinskia at gcc dot gnu dot org
2006-03-21 14:59 ` sam at quux dot dropbear dot id dot au
2006-03-21 23:15 ` pcarlini at suse dot de
2006-03-22 15:14 ` paolo at gcc dot gnu dot org
2006-03-22 15:15 ` pcarlini at suse dot de
2006-03-28 21:58 ` pcarlini at suse dot de
2006-03-28 21:58 ` pcarlini at suse dot de
2006-03-29 0:12 ` paolo at gcc dot gnu dot org
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).