From 1ca1f363d7c228668051aad2e30a4d02c9fcdd0a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 5 Feb 2007 01:17:09 +0000 Subject: new cheesy test by Denis Vlasenko to trigger fclose loop --- test/stdio/fclose-loop.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/stdio/fclose-loop.c (limited to 'test') 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 + * 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 +#include + +int main(int argc, char *argv[]) +{ + FILE* fp; + fp = fopen("/dev/null", "r"); + fclose(fp); + fp = fopen("/dev/zero", "r"); + fclose(fp); + return 0; +} -- cgit v1.2.3