From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16282 invoked by alias); 2 Oct 2002 20:56:02 -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 16261 invoked by uid 71); 2 Oct 2002 20:56:01 -0000 Resent-Date: 2 Oct 2002 20:56:01 -0000 Resent-Message-ID: <20021002205601.16259.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, lennox@cs.columbia.edu Received: (qmail 14900 invoked by uid 61); 2 Oct 2002 20:55:34 -0000 Message-Id: <20021002205534.14886.qmail@sources.redhat.com> Date: Wed, 02 Oct 2002 13:56:00 -0000 From: lennox@cs.columbia.edu Reply-To: lennox@cs.columbia.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/8127: cout << cin.rdbuf() causes infinite loop X-SW-Source: 2002-10/txt/msg00067.txt.bz2 List-Id: >Number: 8127 >Category: libstdc++ >Synopsis: cout << cin.rdbuf() causes infinite loop >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Oct 02 13:56:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: lennox@cs.columbia.edu >Release: gcc-3.1 >Organization: >Environment: sparc-sun-solaris2.8 >Description: The attached trivial implementation of 'cat' goes into an infinite loop when compiled with GCC 3.1. This may be another instance of bug libstdc++/8071, interacting with libstdc++/7744. However, it seems to me that this is a much more significant example of the bug. The problem arises in basic_streambuf::__copy_streambufs. This function calls __sbout->in_avail() to get the number of characters that it can read. If this returns 0, the function loops forever calling __sbout->sputn(__sbin->gptr(), 0). This is a regression from gcc 2.95.2, which executes this code correctly. (I haven't tested this code with GCC 3.3 mainline, but I don't see anything in GNATS or viewcvs which would indicate that this code has changed since 3.1.) >How-To-Repeat: Compile the attached program, and run it with standard input coming from somewhere. E.g.: grandcentral $ g++-2.95.2 -Wall -g -O2 -o test-rdbuf test-rdbuf.cxx grandcentral $ ./test-rdbuf < /etc/nodename grandcentral.cs.columbia.edu grandcentral $ g++ -Wall -g -O2 -o test-rdbuf test-rdbuf.cxx grandcentral $ ./test-rdbuf < /etc/nodename ^C >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="test-rdbuf.cxx" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="test-rdbuf.cxx" I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewog IGNvdXQgPDwgY2luLnJkYnVmKCk7Cn0K