[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GNU M4 1.9a] testsuite: 52 59 60 61 62 failed
From: |
Eric Blake |
Subject: |
Re: [GNU M4 1.9a] testsuite: 52 59 60 61 62 failed |
Date: |
Sat, 14 Oct 2006 09:21:46 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Eric Blake on 10/14/2006 7:22 AM:
>>> --- - 2006-10-14 14:48:50.649837000 +0200
>>> +++ /home/ralf/download/cvs/m4/build/tests/testsuite.dir/at-stderr
>>> 2006-10-14 14:48:50.000000000 +0200
>>> @@ -1,2 +1,3 @@
>>> m4:stdin:1: error reading file `stdin'
>>> +m4: error closing stdin: Bad file descriptor
>>>
>>> 52. others.at:424: 52. stdin closed (others.at:424): FAILED (others.at:438)
>>>
>
> I'll have to look closer at 52 - all the gnulib patches have been applied
> now, so it may just be an honest difference in opinion between cygwin and
> linux on how stdio.h handles a closed fd 0 in error output. If that is
> the case, then I will need to patch the testsuite to be more tolerant.
OK, I found the problem. POSIX states that use of stdin after it has been
fclose'd is undefined, but m4 was doing just that. This test program
shows the difference in behavior between cygwin and linux:
$ cat foo.c
#include <stdio.h>
#include <string.h>
#include <errno.h>
int
main ()
{
int i;
errno = 0;
i = getc (stdin);
printf ("read got %d, errno %d %s\n", i, errno, strerror (errno));
errno = 0;
i = ferror (stdin);
printf ("ferror got %d, errno %d %s\n", i, errno, strerror (errno));
errno = 0;
i = fclose (stdin);
printf ("first fclose got %d, errno %d %s\n", i, errno, strerror (errno));
errno = 0;
i = fclose (stdin);
printf ("second fclose got %d, errno %d %s\n", i, errno, strerror (errno));
return 0;
}
cygwin$ ./foo <&-
read got -1, errno 9 Bad file descriptor
ferror got 1, errno 0 No error
first fclose got -1, errno 9 Bad file descriptor
second fclose got 0, errno 0 No error
linux$ ./foo <&-
read got -1, errno 9 Bad file descriptor
ferror got 1, errno 0 Success
first fclose got -1, errno 9 Bad file descriptor
second fclose got -1, errno 0 Success
It's a little disconcerting that glibc returns EOF, but does not report
EBADF on the second failure of fclose() (a return of EOF should always be
accompanied by an errno, in my mind). But it is not a glibc bug, since
POSIX states that it is undefined behavior. So here's the patch to avoid
closing stdin twice. The branch needs the same patch.
2006-10-14 Eric Blake <address@hidden>
* m4/input.c (file_clean): Don't close stdin twice, POSIX says it
is not portable.
Reported by Ralf Wildenhues.
Index: m4/input.c
===================================================================
RCS file: /sources/m4/m4/m4/input.c,v
retrieving revision 1.53
diff -u -p -r1.53 input.c
- --- m4/input.c 13 Oct 2006 16:46:47 -0000 1.53
+++ m4/input.c 14 Oct 2006 15:16:20 -0000
@@ -298,7 +298,8 @@ file_clean (m4_input_block *me, m4 *cont
{
m4_error (context, 0, 0, _("error reading file `%s'"),
m4_get_current_file (context));
- - fclose (me->u.u_f.file);
+ if (me->u.u_f.close)
+ fclose (me->u.u_f.file);
}
else if (me->u.u_f.close && fclose (me->u.u_f.file) == EOF)
m4_error (context, 0, errno, _("error reading file `%s'"),
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFMQCK84KuGfSFAYARAqc5AJ9gk0aSY05ArAFKa1fZOhar6Rf+SACeNHX4
yn9FWxWS3pI/eC2NRCwX7E0=
=P/ma
-----END PGP SIGNATURE-----
- Re: [GNU M4 1.9a] testsuite: 52 59 60 61 62 failed,
Eric Blake <=