summaryrefslogtreecommitdiff
path: root/test/stdio/fclose-loop.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-02-05 01:17:09 +0000
committerMike Frysinger <vapier@gentoo.org>2007-02-05 01:17:09 +0000
commit1ca1f363d7c228668051aad2e30a4d02c9fcdd0a (patch)
tree846b65e6bff77ad87614ed7b30a4f5279ca658f5 /test/stdio/fclose-loop.c
parent8ceaf7c737b375d4d90afd8051d0b23aede22d96 (diff)
new cheesy test by Denis Vlasenko to trigger fclose loop
Diffstat (limited to 'test/stdio/fclose-loop.c')
-rw-r--r--test/stdio/fclose-loop.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/stdio/fclose-loop.c b/test/stdio/fclose-loop.c
new file mode 100644
index 000000000..fc0cc424a
--- /dev/null
+++ b/test/stdio/fclose-loop.c
@@ -0,0 +1,21 @@
+/* From: Denis Vlasenko <vda.linux@googlemail.com>
+ * With certain combination of .config options fclose() does not
+ * remove FILE* pointer from _stdio_openlist. As a result, subsequent
+ * fopen() may allocate new FILE structure exactly in place of one
+ * freed by previous fclose(), which then makes _stdio_openlist
+ * circularlt looped. The following program will enter infinite loop
+ * trying to walk _stdio_openlist in exit():
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ FILE* fp;
+ fp = fopen("/dev/null", "r");
+ fclose(fp);
+ fp = fopen("/dev/zero", "r");
+ fclose(fp);
+ return 0;
+}