public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/27602] New: fflush(NULL) hangs when getc() ongoing
@ 2021-03-18 10:59 samuel.thibault@ens-lyon.org
  2021-03-18 11:23 ` [Bug stdio/27602] " schwab@linux-m68k.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: samuel.thibault@ens-lyon.org @ 2021-03-18 10:59 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27602

            Bug ID: 27602
           Summary: fflush(NULL) hangs when getc() ongoing
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: samuel.thibault@ens-lyon.org
  Target Milestone: ---

Created attachment 13320
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13320&action=edit
testcase

Hello,

The attached testcase hangs: a thread is blocked in getc(stdin), and the main
thread tries to call fflush(NULL), but that tries to lock stdin, and that's
already locked by getc, and thus cannot proceed.

Samuel

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug stdio/27602] fflush(NULL) hangs when getc() ongoing
  2021-03-18 10:59 [Bug stdio/27602] New: fflush(NULL) hangs when getc() ongoing samuel.thibault@ens-lyon.org
@ 2021-03-18 11:23 ` schwab@linux-m68k.org
  2021-03-18 11:28 ` samuel.thibault@ens-lyon.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2021-03-18 11:23 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27602

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
And that's a bug why?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug stdio/27602] fflush(NULL) hangs when getc() ongoing
  2021-03-18 10:59 [Bug stdio/27602] New: fflush(NULL) hangs when getc() ongoing samuel.thibault@ens-lyon.org
  2021-03-18 11:23 ` [Bug stdio/27602] " schwab@linux-m68k.org
@ 2021-03-18 11:28 ` samuel.thibault@ens-lyon.org
  2021-03-18 11:45 ` schwab@linux-m68k.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: samuel.thibault@ens-lyon.org @ 2021-03-18 11:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27602

--- Comment #2 from Samuel Thibault <samuel.thibault@ens-lyon.org> ---
Well, that is very surprising: fflush is supposed to flush the output, not
interfere with input.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug stdio/27602] fflush(NULL) hangs when getc() ongoing
  2021-03-18 10:59 [Bug stdio/27602] New: fflush(NULL) hangs when getc() ongoing samuel.thibault@ens-lyon.org
  2021-03-18 11:23 ` [Bug stdio/27602] " schwab@linux-m68k.org
  2021-03-18 11:28 ` samuel.thibault@ens-lyon.org
@ 2021-03-18 11:45 ` schwab@linux-m68k.org
  2021-03-18 11:54 ` samuel.thibault@ens-lyon.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2021-03-18 11:45 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27602

--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
But fflush(NULL) needs to inspect each and every stream, in a thread safe way.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug stdio/27602] fflush(NULL) hangs when getc() ongoing
  2021-03-18 10:59 [Bug stdio/27602] New: fflush(NULL) hangs when getc() ongoing samuel.thibault@ens-lyon.org
                   ` (2 preceding siblings ...)
  2021-03-18 11:45 ` schwab@linux-m68k.org
@ 2021-03-18 11:54 ` samuel.thibault@ens-lyon.org
  2021-03-18 12:01 ` schwab@linux-m68k.org
  2021-03-18 12:07 ` samuel.thibault@ens-lyon.org
  5 siblings, 0 replies; 7+ messages in thread
From: samuel.thibault@ens-lyon.org @ 2021-03-18 11:54 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27602

--- Comment #4 from Samuel Thibault <samuel.thibault@ens-lyon.org> ---
Sure, I understand why technically it does hang, but it is still surprising to
see that it would block just because a getc is ongoing. If it was a write on a
pipe which is full, that wouldn't be surprising.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug stdio/27602] fflush(NULL) hangs when getc() ongoing
  2021-03-18 10:59 [Bug stdio/27602] New: fflush(NULL) hangs when getc() ongoing samuel.thibault@ens-lyon.org
                   ` (3 preceding siblings ...)
  2021-03-18 11:54 ` samuel.thibault@ens-lyon.org
@ 2021-03-18 12:01 ` schwab@linux-m68k.org
  2021-03-18 12:07 ` samuel.thibault@ens-lyon.org
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2021-03-18 12:01 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27602

--- Comment #5 from Andreas Schwab <schwab@linux-m68k.org> ---
The stream is locked, so no other thread can use it.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug stdio/27602] fflush(NULL) hangs when getc() ongoing
  2021-03-18 10:59 [Bug stdio/27602] New: fflush(NULL) hangs when getc() ongoing samuel.thibault@ens-lyon.org
                   ` (4 preceding siblings ...)
  2021-03-18 12:01 ` schwab@linux-m68k.org
@ 2021-03-18 12:07 ` samuel.thibault@ens-lyon.org
  5 siblings, 0 replies; 7+ messages in thread
From: samuel.thibault@ens-lyon.org @ 2021-03-18 12:07 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27602

Samuel Thibault <samuel.thibault@ens-lyon.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |NOTABUG
             Status|NEW                         |RESOLVED

--- Comment #6 from Samuel Thibault <samuel.thibault@ens-lyon.org> ---
> The stream is locked

“
All functions that reference ( FILE *) objects shall behave as if they use
flockfile() and funlockfile() internally to obtain ownership of these (FILE *)
objects.
”

Ah, alright then.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2021-03-18 12:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 10:59 [Bug stdio/27602] New: fflush(NULL) hangs when getc() ongoing samuel.thibault@ens-lyon.org
2021-03-18 11:23 ` [Bug stdio/27602] " schwab@linux-m68k.org
2021-03-18 11:28 ` samuel.thibault@ens-lyon.org
2021-03-18 11:45 ` schwab@linux-m68k.org
2021-03-18 11:54 ` samuel.thibault@ens-lyon.org
2021-03-18 12:01 ` schwab@linux-m68k.org
2021-03-18 12:07 ` samuel.thibault@ens-lyon.org

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