After build a new version of procps using the "-Os" flag for gcc, all its (procps) software (ps, top, etc) were failing due to a segmentation fault. I couldn't find a report about that at Bugzilla, but I did find one at "http://www.netdomination.org/~stkn/index.php?/archives/24-Anatomy-of-a-segfault....html". Although the author of that report was using ulibc (and I glibc), it applied perfectly to my case. After I removed the "-ffast-math" from the procps compile command, everything worked fine again.
http://gcc.gnu.org/ml/gcc-patches/2006-03/msg01179.html Caused by the patch at: http://gcc.gnu.org/ml/gcc/2005-08/msg00281.html
The main problem is bug 27537. That is -Os aligns stack at 4 bytes and the other part of i386 backend assumes stack aliged at 16byte. We can word around this by 1. Don't include crtfastmath.o for -m32. 2. Make crtfastmath.o dummy for -m32. 3. Use a static variable to align at 16byte. 4. Compile crtfastmath.o with -mstackrealign. Need to backport -mstackrealign to 4.1? 5. Fix i386 backend only to assume 4byte stack alignment. The easiest one is #2 or #3. The idel one is #5.
Hi, because of quite serve register pressure issues, I don't like much idea of GCC realocating stack transparently (it is also dificult to teach reload to decide when alignment is needed). Safe bugfix for 4.2 seems to be this: PR target/28621 * crtfastmath.c (force_align_arg_pointer): Force stack alignment. Index: config/i386/crtfastmath.c =================================================================== -u -L config/i386/crtfastmath.c (revision 115987) -L config/i386/crtfastmath.c (working copy) config/i386/.svn/text-base/crtfastmath.c.svn-base config/i386/crtfastmath.c --- config/i386/crtfastmath.c (revision 115987) +++ config/i386/crtfastmath.c (working copy) @@ -38,6 +38,9 @@ #define SSE (1 << 25) static void __attribute__((constructor)) +#ifndef __x86_64__ +__attribute__ ((force_align_arg_pointer)) +#endif set_fast_math (void) { #ifndef __x86_64__ Does it help? Honza
(In reply to comment #3) > --- config/i386/crtfastmath.c (revision 115987) > +++ config/i386/crtfastmath.c (working copy) > @@ -38,6 +38,9 @@ > #define SSE (1 << 25) > > static void __attribute__((constructor)) > +#ifndef __x86_64__ > +__attribute__ ((force_align_arg_pointer)) > +#endif > set_fast_math (void) > { > #ifndef __x86_64__ > > Does it help? I applied this patch against the gcc 4.1.1, but the bug is still there (at least procps keeps segfaulting).
(In reply to comment #4) > I applied this patch against the gcc 4.1.1, but the bug is still there (at > least procps keeps segfaulting). 4.1.1 did not have the force_align_arg_pointer attribute so what do you expect.
Sorry, but I didn't know that. I reported the bug against GCC 4.1.1 and the target milestone set for it is GCC 4.1.2. So, I expected that patch to work with gcc 4.1.x. The 'force_align_arg_pointer' attribute is available at GCC 4.1.2 or just GCC 4.2.x?
(In reply to comment #6) > Sorry, but I didn't know that. I reported the bug against GCC 4.1.1 and the > target milestone set for it is GCC 4.1.2. So, I expected that patch to work > with gcc 4.1.x. The 'force_align_arg_pointer' attribute is available at GCC > 4.1.2 or just GCC 4.2.x? Just 4.2.0 which right now the trunk (aka mainline) of the svn.
Subject: Bug 28621 Author: pbrook Date: Fri Aug 25 20:39:48 2006 New Revision: 116431 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116431 Log: 2006-08-25 Jan Hubicka <jh@suse.cz> PR target/28621 * config/i386/crtfastmath.c (set_fast_math): Force stack alignment. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/crtfastmath.c
Fix for PR 13685 should also fix this bug. In fact, we can back out the change in comment #3.
We can even back out the patch and close it as a dup for PR 13685.
(In reply to comment #10) > We can even back out the patch and close it as a dup for PR 13685. Not really and here is why: -Os on the file containing main will still crash. -Os -msse on the file with main will not crash.
Subject: Bug 28621 Author: hjl Date: Mon Sep 11 21:34:06 2006 New Revision: 116860 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116860 Log: gcc/ 2006-09-11 H.J. Lu <hongjiu.lu@intel.com> PR target/13685 PR target/27537 PR target/28621 * config/i386/i386.c (override_options): Always default to 16 byte stack boundary. gcc/testsuite/ 2006-09-11 H.J. Lu <hongjiu.lu@intel.com> PR target/13685 * gcc.target/i386/pr13685.c: New test. Added: trunk/gcc/testsuite/gcc.target/i386/pr13685.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 28621 Author: hjl Date: Tue Sep 12 02:54:42 2006 New Revision: 116870 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116870 Log: gcc/ 2006-09-11 H.J. Lu <hongjiu.lu@intel.com> PR target/13685 PR target/27537 PR target/28621 * config/i386/i386.c (override_options): Always default to 16 byte stack boundary. gcc/testsuite/ 2006-09-11 H.J. Lu <hongjiu.lu@intel.com> PR target/13685 * gcc.target/i386/pr13685.c: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gcc.target/i386/pr13685.c Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/config/i386/i386.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Fixed.