-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Karl Berry on 12/21/2009 4:51 PM: > It's definitely a compiler problem. That extern inline asm alias trickery > > The gcc people say that the behavior is correct; not a bug. > (I don't understand all of their replies, but the conclusion seems clear.) > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440 > > I don't know if there is a way to change the configure test so it is > robust against this particular problem.
Yes, we can still change configure to be robust against this problem, by adding an alarm() call to force a non-zero exit if the compiler mis-compiled the program (it doesn't fix the underlying bug of the compiler vs. system header mismatch, nor of why fixincludes didn't work when the compiler was installed, but at least it would prevent configure from hanging). Any objections to the following? - -- Don't work too hard, make some time for fun as well! Eric Blake [email protected] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkswyFoACgkQ84KuGfSFAYArLACfSm1Bl/NcKGFWrmeMjwBCZScs DdcAnR9AS6CFjTf/wrFCeksPOOSgHJPj =IkRI -----END PGP SIGNATURE-----
>From 78cca4053e17efa6e755d05be99cd69f2911db11 Mon Sep 17 00:00:00 2001 From: Eric Blake <[email protected]> Date: Tue, 22 Dec 2009 06:19:48 -0700 Subject: [PATCH] btowc: avoid infinite loop Older glibc headers declared btowc with an extern inline, expecting old gnu semantics. Newer gcc uses C99 semantics, and ends up turning btowc on a constant into an infinite tail recursion. It is not yet known why gcc's fixincludes does not work around this. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440 * m4/btowc.m4 (gl_FUNC_BTOWC): Add a timeout. * doc/posix-functions/btowc.texi (btowc): Document the problem. Reported by Karl Berry. Signed-off-by: Eric Blake <[email protected]> --- ChangeLog | 7 +++++++ doc/posix-functions/btowc.texi | 3 +++ m4/btowc.m4 | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index efd18cc..92dcc33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-12-22 Eric Blake <[email protected]> + + btowc: avoid infinite loop + * m4/btowc.m4 (gl_FUNC_BTOWC): Add a timeout. + * doc/posix-functions/btowc.texi (btowc): Document the problem. + Reported by Karl Berry. + 2009-11-17 Eric Blake <[email protected]> manywarnings: add more warnings diff --git a/doc/posix-functions/btowc.texi b/doc/posix-functions/btowc.texi index b58fa84..03de13f 100644 --- a/doc/posix-functions/btowc.texi +++ b/doc/posix-functions/btowc.texi @@ -21,4 +21,7 @@ btowc @item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. +...@item +Improperly mixing headers from an older glibc with a newer gcc can +cause miscompilation where btowc enters an infinite tail-recursion. @end itemize diff --git a/m4/btowc.m4 b/m4/btowc.m4 index b46f74f..0f2c9af 100644 --- a/m4/btowc.m4 +++ b/m4/btowc.m4 @@ -1,4 +1,4 @@ -# btowc.m4 serial 4 +# btowc.m4 serial 5 dnl Copyright (C) 2008-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -36,8 +36,14 @@ changequote([,])dnl #include <stdio.h> #include <string.h> #include <wchar.h> +#include <unistd.h> +#include <signal.h> int main () { + /* A mismatch between glibc and gcc can cause btowc to go into an + infinite loop. All platforms that lack alarm also lack btowc. */ + signal (SIGALRM, SIG_DFL); + alarm (5); if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) { if (btowc (EOF) != WEOF) -- 1.6.5.rc1
