public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/28099] New: fcloseall doesn't close anything
@ 2021-07-18 16:10 crrodriguez at opensuse dot org
  2021-07-18 16:25 ` [Bug stdio/28099] " schwab@linux-m68k.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: crrodriguez at opensuse dot org @ 2021-07-18 16:10 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 28099
           Summary: fcloseall doesn't close anything
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: crrodriguez at opensuse dot org
  Target Milestone: ---

Example to demonstrate de bug.

#define _GNU_SOURCE
#include <stdio.h>
#include <assert.h>

int main(void)
{
    FILE *fp, *fp1;
    fp = tmpfile();
    fp1 =tmpfile();
    assert ( fcloseall() == 0 );
    assert ( fputs("doh", fp) < 0 );
    assert ( fputs("bla", fp1) < 0 );
    return 0;
}

after the fcloseall() call all writes to the stream must fail..it really does
not appear to be doing anything.

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

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

* [Bug stdio/28099] fcloseall doesn't close anything
  2021-07-18 16:10 [Bug stdio/28099] New: fcloseall doesn't close anything crrodriguez at opensuse dot org
@ 2021-07-18 16:25 ` schwab@linux-m68k.org
  2021-07-18 16:54 ` crrodriguez at opensuse dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: schwab@linux-m68k.org @ 2021-07-18 16:25 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
There is no way to find out because any use of any FILE pointer after fcloseall
is undefined.

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

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

* [Bug stdio/28099] fcloseall doesn't close anything
  2021-07-18 16:10 [Bug stdio/28099] New: fcloseall doesn't close anything crrodriguez at opensuse dot org
  2021-07-18 16:25 ` [Bug stdio/28099] " schwab@linux-m68k.org
@ 2021-07-18 16:54 ` crrodriguez at opensuse dot org
  2021-09-01  8:02 ` infor at rudhar dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: crrodriguez at opensuse dot org @ 2021-07-18 16:54 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 from Cristian Rodríguez <crrodriguez at opensuse dot org> ---
(In reply to Andreas Schwab from comment #1)
> There is no way to find out because any use of any FILE pointer after
> fcloseall is undefined.

yes, I guess I wrote the wrong test.. :-) my point is that fcloseall() is not
closing streams, at least it is not doing what the manual says..

"This function causes all open streams of the process to be closed and the
connections to corresponding files to be broken." the streams are NOT
closed..fds are not closed either.

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

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

* [Bug stdio/28099] fcloseall doesn't close anything
  2021-07-18 16:10 [Bug stdio/28099] New: fcloseall doesn't close anything crrodriguez at opensuse dot org
  2021-07-18 16:25 ` [Bug stdio/28099] " schwab@linux-m68k.org
  2021-07-18 16:54 ` crrodriguez at opensuse dot org
@ 2021-09-01  8:02 ` infor at rudhar dot com
  2021-09-01 14:27 ` crrodriguez at opensuse dot org
  2021-09-01 15:27 ` crrodriguez at opensuse dot org
  4 siblings, 0 replies; 6+ messages in thread
From: infor at rudhar dot com @ 2021-09-01  8:02 UTC (permalink / raw)
  To: glibc-bugs

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

Ruud Harmsen <infor at rudhar dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |infor at rudhar dot com

--- Comment #3 from Ruud Harmsen <infor at rudhar dot com> ---
Or perhaps the streams and file descriptors ARE closed, but fputs error
checking isn't working properly? Cf.
https://sourceware.org/bugzilla/show_bug.cgi?id=20632, where I found the first
fputws to a closed stderr (that is, a close(2) was done) does return -1, as it
should, but subsequent calls of  fputws return 1 as if they are OK. But they
aren't, no text appears.

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

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

* [Bug stdio/28099] fcloseall doesn't close anything
  2021-07-18 16:10 [Bug stdio/28099] New: fcloseall doesn't close anything crrodriguez at opensuse dot org
                   ` (2 preceding siblings ...)
  2021-09-01  8:02 ` infor at rudhar dot com
@ 2021-09-01 14:27 ` crrodriguez at opensuse dot org
  2021-09-01 15:27 ` crrodriguez at opensuse dot org
  4 siblings, 0 replies; 6+ messages in thread
From: crrodriguez at opensuse dot org @ 2021-09-01 14:27 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #4 from Cristian Rodríguez <crrodriguez at opensuse dot org> ---
(In reply to Ruud Harmsen from comment #3)
> Or perhaps the streams and file descriptors ARE closed, but fputs error
> checking isn't working properly? Cf.
> https://sourceware.org/bugzilla/show_bug.cgi?id=20632, where I found the
> first fputws to a closed stderr (that is, a close(2) was done) does return
> -1, as it should, but subsequent calls of  fputws return 1 as if they are
> OK. But they aren't, no text appears.

In my test, file descriptors are not closed by a call to fcloseall()

Andreas is entirely right that doing anything with fp and fp1 after fcloseall()
is UB. (it woould be incredible nice to get an error/assertion/fortify_fail or
whatever in that case but that is again not required by anything) however when
I tested nothing was closed in the first place.

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

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

* [Bug stdio/28099] fcloseall doesn't close anything
  2021-07-18 16:10 [Bug stdio/28099] New: fcloseall doesn't close anything crrodriguez at opensuse dot org
                   ` (3 preceding siblings ...)
  2021-09-01 14:27 ` crrodriguez at opensuse dot org
@ 2021-09-01 15:27 ` crrodriguez at opensuse dot org
  4 siblings, 0 replies; 6+ messages in thread
From: crrodriguez at opensuse dot org @ 2021-09-01 15:27 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #5 from Cristian Rodríguez <crrodriguez at opensuse dot org> ---
expectation : fcloseall() sorts all file descriptors associated with FILE* s in
the current thread, calls close_range(2) on them..

..and maybe..just maybe add a warning attribute to the function discouraging
people to use it..

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

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

end of thread, other threads:[~2021-09-01 15:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-18 16:10 [Bug stdio/28099] New: fcloseall doesn't close anything crrodriguez at opensuse dot org
2021-07-18 16:25 ` [Bug stdio/28099] " schwab@linux-m68k.org
2021-07-18 16:54 ` crrodriguez at opensuse dot org
2021-09-01  8:02 ` infor at rudhar dot com
2021-09-01 14:27 ` crrodriguez at opensuse dot org
2021-09-01 15:27 ` crrodriguez at opensuse dot 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).