public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* RE: libstdc++/9533: Regression: Can't read from tty with ifstream
@ 2003-03-03 13:16 Pétur Runólfsson
0 siblings, 0 replies; 7+ messages in thread
From: Pétur Runólfsson @ 2003-03-03 13:16 UTC (permalink / raw)
To: paolo; +Cc: gcc-prs
The following reply was made to PR libstdc++/9533; it has been noted by GNATS.
From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
To: <paolo@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>,
<nobody@gcc.gnu.org>,
<gcc-gnats@gcc.gnu.org>
Cc: <libstdc++@gcc.gnu.org>
Subject: RE: libstdc++/9533: Regression: Can't read from tty with ifstream
Date: Mon, 3 Mar 2003 13:09:06 -0000
> Patching: indeed, reverting this hunk of 6746 commit:
> =20
> +
> + // Set input to nonblocking for fifos.
> + if (__mode & ios_base::in)
> + fcntl(this->fd(), F_SETFL, O_NONBLOCK);
> +
> =20
> Fixes the problem without regressing on 6746.
Interesting. I would have thought that removing this would
cause the call to underflow() in basic_filebuf::open() to
block, causing the test case to wait for input *before*
printing out the prompt (this seems to be the reason that
non-blocking input is specified).
So far, this is what I think is going on:
* non-blocking input is specified so underflow() doesn't
block (which is wrong, underflow() should block).
* underflow() must not block because it is called from
open() which must not block.
* open() calls underflow() so that in_avail() will return
non-zero after open() (libstdc++/6746).
However, I don't see how calling underflow() from open()
fixes libstdc++/6746. Unless I am missing something,
readsome will return up to BUFSIZ characters, and then
return 0 until the end of time.
Petur
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: libstdc++/9533: Regression: Can't read from tty with ifstream
@ 2003-03-03 13:26 Paolo Carlini
0 siblings, 0 replies; 7+ messages in thread
From: Paolo Carlini @ 2003-03-03 13:26 UTC (permalink / raw)
To: paolo; +Cc: gcc-prs
The following reply was made to PR libstdc++/9533; it has been noted by GNATS.
From: Paolo Carlini <pcarlini@unitus.it>
To: =?ISO-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
Cc: paolo@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org,
gcc-gnats@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: libstdc++/9533: Regression: Can't read from tty with ifstream
Date: Mon, 03 Mar 2003 14:16:37 +0100
P=E9tur Run=F3lfsson wrote:
>> Patching: indeed, reverting this hunk of 6746 commit:
>> =20
>> +
>> + // Set input to nonblocking for fifos.
>> + if (__mode & ios_base::in)
>> + fcntl(this->fd(), F_SETFL, O_NONBLOCK);
>> +
>> =20
>> Fixes the problem without regressing on 6746.
>> =20
>>
>Interesting. I would have thought that removing this would
>cause the call to underflow() in basic_filebuf::open() to
>block, causing the test case to wait for input *before*
>printing out the prompt (this seems to be the reason that
>non-blocking input is specified).
>
Yes, you are right. My bad.
I didn't notice that since was using a further reduced :( testcase.
Also, we got a regression elsewhere by simply reverting that hunk (not=20
on 6746): see
the libstdc++ list.
>So far, this is what I think is going on:
>* non-blocking input is specified so underflow() doesn't
> block (which is wrong, underflow() should block).
>* underflow() must not block because it is called from
> open() which must not block.
>* open() calls underflow() so that in_avail() will return
> non-zero after open() (libstdc++/6746).
>
Agreed.
>However, I don't see how calling underflow() from open()
>fixes libstdc++/6746.
>
I concur, but in fact it does.
> Unless I am missing something,
>readsome will return up to BUFSIZ characters, and then
>return 0 until the end of time.
> =20
>
Paolo.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: libstdc++/9533: Regression: Can't read from tty with ifstream
@ 2003-03-03 12:25 paolo
0 siblings, 0 replies; 7+ messages in thread
From: paolo @ 2003-03-03 12:25 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, paolo, peturr02
Synopsis: Regression: Can't read from tty with ifstream
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Mon Mar 3 12:25:22 2003
Responsible-Changed-Why:
Patching: indeed, reverting this hunk of 6746 commit:
+
+ // Set input to nonblocking for fifos.
+ if (__mode & ios_base::in)
+ fcntl(this->fd(), F_SETFL, O_NONBLOCK);
+
Fixes the problem without regressing on 6746.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9533
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: libstdc++/9533: Regression: Can't read from tty with ifstream
@ 2003-03-03 10:46 Pétur Runólfsson
0 siblings, 0 replies; 7+ messages in thread
From: Pétur Runólfsson @ 2003-03-03 10:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR libstdc++/9533; it has been noted by GNATS.
From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
To: <paolo@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>,
<gcc-prs@gcc.gnu.org>,
<nobody@gcc.gnu.org>,
=?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>,
<gcc-gnats@gcc.gnu.org>
Cc:
Subject: RE: libstdc++/9533: Regression: Can't read from tty with ifstream
Date: Mon, 3 Mar 2003 10:44:37 -0000
> Something is wrong, agreed, but I cannot reproduce the
> regression thing: for me (*), 3.2.2 asks the number but
> then hangs upon <newline>. Same behaviour 3.0.4.
Just to clarify, this is of course correct behaviour since the
input stream is in fully buffered mode (*). The "hang" happens
because filebuf::underflow() blocks until either BUFSIZ
characters are entered or EOF occurs.
Petur
* The reason the test case uses fully buffered is that
unbuffered doesn't work (libstdc++/9024).
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: libstdc++/9533: Regression: Can't read from tty with ifstream
@ 2003-03-02 18:26 Pétur Runólfsson
0 siblings, 0 replies; 7+ messages in thread
From: Pétur Runólfsson @ 2003-03-02 18:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR libstdc++/9533; it has been noted by GNATS.
From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
To: <paolo@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>,
<nobody@gcc.gnu.org>,
=?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>,
<gcc-gnats@gcc.gnu.org>
Cc:
Subject: RE: libstdc++/9533: Regression: Can't read from tty with ifstream
Date: Sun, 2 Mar 2003 18:23:24 -0000
> Something is wrong, agreed, but I cannot reproduce the
> regression thing: for me (*), 3.2.2 asks the number but
> then hangs upon <newline>. Same behaviour 3.0.4.
Yes, that is the same behaviour I get (with 3.2.1). However,
mainline fails in a different manner (the program just exits).
I believe the culprit is this code in basic_file_stdio.cc
(__basic_file<char>::open), which is not present on the 3.2
branch:
#if defined (F_SETFL) && defined (O_NONBLOCK)
// Set input to nonblocking for fifos.
if (__mode & ios_base::in)
fcntl(this->fd(), F_SETFL, O_NONBLOCK);
#endif
This causes fread to return 0 immediately instead of waiting
for input, which in turn causes underflow to return eof().
Also, I think this counts as a regression, since the hang
(when compiled with 3.2.x) can be avoided by setting the
buffer size to 1.
Petur
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: libstdc++/9533: Regression: Can't read from tty with ifstream
@ 2003-03-02 18:08 paolo
0 siblings, 0 replies; 7+ messages in thread
From: paolo @ 2003-03-02 18:08 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, peturr02
Synopsis: Regression: Can't read from tty with ifstream
State-Changed-From-To: open->analyzed
State-Changed-By: paolo
State-Changed-When: Sun Mar 2 18:08:02 2003
State-Changed-Why:
Something is wrong, agreed, but I cannot reproduce the
regression thing: for me (*), 3.2.2 asks the number but
then hangs upon <newline>. Same behaviour 3.0.4.
(*) x86, glibc2.3.1, linux2.4.20.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9533
^ permalink raw reply [flat|nested] 7+ messages in thread
* libstdc++/9533: Regression: Can't read from tty with ifstream
@ 2003-02-01 12:16 peturr02
0 siblings, 0 replies; 7+ messages in thread
From: peturr02 @ 2003-02-01 12:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 9533
>Category: libstdc++
>Synopsis: Regression: Can't read from tty with ifstream
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 01 12:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: peturr02@ru.is
>Release: gcc version 3.3 20030106 (prerelease)
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
If /dev/tty is opened with an ifstream, nothing can be read. The attached program exits immediately when compiled with gcc-20030106, but outputs the prompt and then waits for input when compiled with gcc-3.2.1.
[petur@interim ttybug]$ g++321 -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs
Configured with: ../gcc-3.2.1/configure --program-suffix=321 --enable-threads=posix --enable-version-specific-runtime-libs --enable-languages=c,c++
Thread model: posix
gcc version 3.2.1
[petur@interim ttybug]$ g++0106 -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ../gcc-20030106/configure --program-suffix=0106 --enable-threads=posix --enable-version-specific-runtime-libs --enable-languages=c,c++ --enable-clocale=gnu
Thread model: posix
gcc version 3.3 20030106 (prerelease)
[petur@interim ttybug]$ rm ttybug && make CXX=g++321
g++321 -static ttybug.cc -o ttybug
[petur@interim ttybug]$ ./ttybug < /dev/zero > /dev/null
Enter a number: 4
You entered: 4
[petur@interim ttybug]$ rm ttybug && make CXX=g++0106
g++0106 -static ttybug.cc -o ttybug
[petur@interim ttybug]$ ./ttybug < /dev/zero > /dev/null
Enter a number: You entered: -1073743396
>How-To-Repeat:
See attachment.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="ttybug.cc"
Content-Disposition: inline; filename="ttybug.cc"
#include <fstream>
int main()
{
using namespace std;
ifstream in ("/dev/tty");
ofstream out ("/dev/tty");
in.tie(&out);
out << "Enter a number: ";
int i;
in >> i;
out << "You entered: " << i << endl;
return 0;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-03-03 13:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-03 13:16 libstdc++/9533: Regression: Can't read from tty with ifstream Pétur Runólfsson
-- strict thread matches above, loose matches on Subject: below --
2003-03-03 13:26 Paolo Carlini
2003-03-03 12:25 paolo
2003-03-03 10:46 Pétur Runólfsson
2003-03-02 18:26 Pétur Runólfsson
2003-03-02 18:08 paolo
2003-02-01 12:16 peturr02
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).