public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/35763]  New: std::cout loses whole blocks of output if interrupted by signal without SA_RESTART
@ 2008-03-30  3:41 zlynx at acm dot org
  2008-03-30  3:43 ` [Bug libstdc++/35763] " zlynx at acm dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: zlynx at acm dot org @ 2008-03-30  3:41 UTC (permalink / raw)
  To: gcc-bugs

I noticed this when running a program that uses a periodic timer signal.  The
sigaction did not set SA_RESTART.  During program runs, huge chunks of console
output would disappear.

I sort of tracked this down to the code in libstdc++ that uses fwrite to do the
output of cout and cerr.  That is a bit weird, I expected it to be using the
basic_file operations on fd 0 instead.

In summary, it appears to call fwrite and never check the error return, then it
increments the streambuf pointers and loses that whole output block.


-- 
           Summary: std::cout loses whole blocks of output if interrupted by
                    signal without SA_RESTART
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zlynx at acm dot org
  GCC host triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35763


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/35763] std::cout loses whole blocks of output if interrupted by signal without SA_RESTART
  2008-03-30  3:41 [Bug libstdc++/35763] New: std::cout loses whole blocks of output if interrupted by signal without SA_RESTART zlynx at acm dot org
@ 2008-03-30  3:43 ` zlynx at acm dot org
  2008-03-30  3:47 ` zlynx at acm dot org
  2008-03-30  9:24 ` pcarlini at suse dot de
  2 siblings, 0 replies; 4+ messages in thread
From: zlynx at acm dot org @ 2008-03-30  3:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from zlynx at acm dot org  2008-03-30 03:43 -------
Forgot to mention, I filed a bug for fwrite too:
http://sources.redhat.com/bugzilla/show_bug.cgi?id=5998

Until they fix that (if they do) it will be useless to check fwrite's return
value since you can't know how many bytes were written.

I think the fix would be to use write directly or to use the file operations
(which do seem to use write directly and check for EINTR returns) on fd 0.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35763


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/35763] std::cout loses whole blocks of output if interrupted by signal without SA_RESTART
  2008-03-30  3:41 [Bug libstdc++/35763] New: std::cout loses whole blocks of output if interrupted by signal without SA_RESTART zlynx at acm dot org
  2008-03-30  3:43 ` [Bug libstdc++/35763] " zlynx at acm dot org
@ 2008-03-30  3:47 ` zlynx at acm dot org
  2008-03-30  9:24 ` pcarlini at suse dot de
  2 siblings, 0 replies; 4+ messages in thread
From: zlynx at acm dot org @ 2008-03-30  3:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from zlynx at acm dot org  2008-03-30 03:46 -------
Created an attachment (id=15399)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15399&action=view)
test program, build: g++ timer-test.cc -lrt


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35763


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/35763] std::cout loses whole blocks of output if interrupted by signal without SA_RESTART
  2008-03-30  3:41 [Bug libstdc++/35763] New: std::cout loses whole blocks of output if interrupted by signal without SA_RESTART zlynx at acm dot org
  2008-03-30  3:43 ` [Bug libstdc++/35763] " zlynx at acm dot org
  2008-03-30  3:47 ` zlynx at acm dot org
@ 2008-03-30  9:24 ` pcarlini at suse dot de
  2 siblings, 0 replies; 4+ messages in thread
From: pcarlini at suse dot de @ 2008-03-30  9:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pcarlini at suse dot de  2008-03-30 09:24 -------
This is tightly coupled to libstdc++/35353: in the current design, when
sync_with_stdio is false (by default), the stream is non-converting and synced
with C stdio, simply forwards to stdio functions. Unfortunately, the fix is not
forthcoming, there are very serious performance implications, and binary
compatibility issues (which probably can be solve only by breaking the ABI).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35763


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-03-30  9:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-30  3:41 [Bug libstdc++/35763] New: std::cout loses whole blocks of output if interrupted by signal without SA_RESTART zlynx at acm dot org
2008-03-30  3:43 ` [Bug libstdc++/35763] " zlynx at acm dot org
2008-03-30  3:47 ` zlynx at acm dot org
2008-03-30  9:24 ` pcarlini at suse dot de

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).