path: root/src/stdio/fclose.c
diff options
authorRich Felker <>2014-08-23 23:35:10 -0400
committerRich Felker <>2014-08-23 23:35:10 -0400
commit5345c9b884e7c4e73eb2c8bb83b8d0df20f95afb (patch)
tree622716518874799c9430d2542f5d063a5906c638 /src/stdio/fclose.c
parentb8ca9eb5301580dcf101753451eee196edceefbd (diff)
fix false ownership of stdio FILEs due to tid reuse
this is analogous commit fffc5cda10e0c5c910b40f7be0d4fa4e15bb3f48 which fixed the corresponding issue for mutexes. the robust list can't be used here because the locks do not share a common layout with mutexes. at some point it may make sense to simply incorporate a mutex object into the FILE structure and use it, but that would be a much more invasive change, and it doesn't mesh well with the current design that uses a simpler code path for internal locking and pulls in the recursive-mutex-like code when the flockfile API is used explicitly.
Diffstat (limited to 'src/stdio/fclose.c')
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c
index 38e8a1e3..317b3c90 100644
--- a/src/stdio/fclose.c
+++ b/src/stdio/fclose.c
@@ -1,4 +1,8 @@
#include "stdio_impl.h"
+#include "libc.h"
+static void dummy(FILE *f) { }
+weak_alias(dummy, __unlist_locked_file);
int fclose(FILE *f)
@@ -7,6 +11,8 @@ int fclose(FILE *f)
+ __unlist_locked_file(f);
if (!(perm = f->flags & F_PERM)) {
if (f->prev) f->prev->next = f->next;