[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer g
From: |
Mike Frysinger |
Subject: |
[Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop |
Date: |
Mon, 5 Oct 2015 11:55:24 -0400 |
we got a report about gnubg hanging on startup when built w/gcc-5:
https://bugs.gentoo.org/551896
but when built w/older versions (<=gcc-4.9), everything worked great.
there seems to be a similar report here from a few months ago:
https://lists.gnu.org/archive/html/bug-gnubg/2015-07/msg00011.html
this is because of bad code in gnubg itself:
http://cvs.savannah.gnu.org/viewvc/gnubg/gnubg/common.h?revision=1.31&view=markup
#if !_GNU_SOURCE && !defined (__attribute__)
/*! \brief GNU C specific attributes, e.g. unused
* // */
#define __attribute__(X)
#endif
when building copying.c, the config.h header is not included, so when it walks
through all the headers, _GNU_SOURCE is not defined. this ends up hitting the
common.h header which disables __attribute__, and then later on glibc headers
are included (such as string.h) which produce bad code when __attribute__ is
disabled. specifically, gnubg ends up with a stub memory/string funcs (like
memset), so when the app starts up, it calls the memset in gnubg itself which
calls itself which causes an infinite loop.
there's two fixes here:
(1) copying.c should include config.h first even if it doesn't use it itself --
local headers that are included most likely rely on it. alternatively, the
copying.c file shouldn't bother including anything since it adds no value.
the file is only declaring strings, and no prototypes are needed for that.
(2) common.h should be changed from checking for _GNU_SOURCE to __GNUC__ since
the attribute is tied to the GNU C compiler. or maybe test whether the
syntax __attribute__ works regardless of other defines.
-mike
signature.asc
Description: Digital signature
- [Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop,
Mike Frysinger <=
- Re: [Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop, Russ Allbery, 2015/10/08
- Re: [Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop, Michael Petch, 2015/10/08
- Re: [Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop, Russ Allbery, 2015/10/08
- Re: [Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop, Philippe Michel, 2015/10/08
- Re: [Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop, Michael Petch, 2015/10/08
- Re: [Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop - FIX NEEDS TESTING, Michael Petch, 2015/10/08
- Re: [Bug-gnubg] bad __attribute__ handling breaks w/newer standards, newer gcc, & glibc and causes infinite loop - FIX NEEDS TESTING, Mike Frysinger, 2015/10/09