From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15513 invoked by alias); 15 Mar 2003 10:56:01 -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 15486 invoked by uid 71); 15 Mar 2003 10:56:00 -0000 Resent-Date: 15 Mar 2003 10:56:00 -0000 Resent-Message-ID: <20030315105600.15483.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, peturr02@ru.is Received: (qmail 13412 invoked by uid 48); 15 Mar 2003 10:50:11 -0000 Message-Id: <20030315105011.13410.qmail@sources.redhat.com> Date: Sat, 15 Mar 2003 10:56:00 -0000 From: peturr02@ru.is Reply-To: peturr02@ru.is To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/10097: filebuf::underflow drops characters. X-SW-Source: 2003-03/txt/msg00971.txt.bz2 List-Id: >Number: 10097 >Category: libstdc++ >Synopsis: filebuf::underflow drops characters. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sat Mar 15 10:56:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: peturr02@ru.is >Release: gcc-3.2.2 >Organization: >Environment: Red Hat Linux 8.0 >Description: filebuf::underflow discards characters that are already in the buffer, this causes those characters to be lost when reading from a pipe. >How-To-Repeat: See attachment. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="showmanycbug.cc" Content-Disposition: inline; filename="showmanycbug.cc" #include #include #include #include #include #include #undef NDEBUG #include class Buf : public std::filebuf { public: int_type pub_underflow() { return underflow(); } std::streamsize pub_showmanyc() { return showmanyc(); } }; int main() { using namespace std; signal(SIGPIPE, SIG_IGN); unlink("xxx"); if (0 != mkfifo("xxx", S_IRWXU)) { assert(false); } int fval = fork(); if (fval == -1) { unlink("xxx"); assert(false); } else if (fval == 0) { filebuf fbout; fbout.open("xxx", ios_base::out); fbout.sputn("0123456789", 10); fbout.pubsync(); sleep(2); fbout.close(); exit(0); } Buf fb; fb.open("xxx", ios_base::in); sleep(1); fb.sgetc(); streamsize n = fb.pub_showmanyc(); while (n > 0) { --n; Buf::int_type c = fb.pub_underflow(); assert(c != Buf::traits_type::eof()); fb.sbumpc(); } fb.close(); return 0; }