libstdc++/8127: cout << cin.rdbuf() causes infinite loop
lennox@cs.columbia.edu
lennox@cs.columbia.edu
Wed Oct 2 13:56:00 GMT 2002
>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
More information about the Gcc-prs
mailing list