Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 340923 - sys-apps/diffutils-2.8.7 gnulib c-stack configure check hangs with better optimizers
Summary: sys-apps/diffutils-2.8.7 gnulib c-stack configure check hangs with better opt...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-14 04:56 UTC by Robert White
Modified: 2011-05-01 19:47 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to configure data to let package build under gcc 4.5 (diffutils-2.8.7-c-stack.patch,831 bytes, patch)
2010-10-14 04:58 UTC, Robert White
Details | Diff
patch to configure data to let package build under gcc 4.5 (diffutils-2.8.7-c-stack.patch,831 bytes, patch)
2010-10-14 05:07 UTC, Robert White
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert White 2010-10-14 04:56:17 UTC
(Yes, I like to play with test-grade builds 8-)

The new optimizer in GCC 4.5 (correctly) turns the tail-recursive c-stack test in the configure script in diffutils-2.8.7 into an endless loop. This causes builds to hang in the configure script.

The one-line patch (here as text, and hopefully attached) fixes the test. I am sure this should go upstream as well, but I don't know where to do that. 8-)


Reproducible: Always

Steps to Reproduce:
1. emerge and gcc-config gcc version 4.5.1
2. emerge --oneshot diffutils


Actual Results:  
will hang in configure forever at the check for stack overruns.

Expected Results:  
oughta just build normally.

The below patch fixes both the configure script and the m4 macro that generated same, so that both kinds of users can stay happy.  By calling "recurse" twice in the return we prevent the tail-recursion-to-loop transformation from eating the recursion. The code should work for old and new compilers equally.

(will attach file as well after bug creation.)

diff -rup diffutils-2.8.7.orig/configure diffutils-2.8.7/configure
--- diffutils-2.8.7.orig/configure      2004-04-13 00:04:38.000000000 -0700
+++ diffutils-2.8.7/configure   2010-10-13 21:45:49.865239663 -0700
@@ -8396,7 +8396,7 @@ cat >>conftest.$ac_ext <<_ACEOF
         {
           char array[500];
           array[0] = 1;
-          return *p + recurse (array);
+          return *p + recurse (array) - recurse (array);
         }
 
         int
diff -rup diffutils-2.8.7.orig/m4/c-stack.m4 diffutils-2.8.7/m4/c-stack.m4
--- diffutils-2.8.7.orig/m4/c-stack.m4  2004-03-07 15:51:10.000000000 -0800
+++ diffutils-2.8.7/m4/c-stack.m4       2010-10-13 21:16:29.326926806 -0700
@@ -102,7 +102,7 @@ AC_DEFUN([AC_SYS_X
Comment 1 Robert White 2010-10-14 04:58:08 UTC
Created attachment 250521 [details, diff]
patch to configure data to let package build under gcc 4.5

Should be safe for all versions of gcc and all versions of diffutils.
Comment 2 Robert White 2010-10-14 05:01:02 UTC
post size limit ate the patch text, but I attached the original (which I successfully tested with an .ebuild in my PORTDIR_OVERLAY directory).
Comment 3 Robert White 2010-10-14 05:03:17 UTC
Comment on attachment 250521 [details, diff]
patch to configure data to let package build under gcc 4.5

just noticed I use "+" in one place and "-" in the other. whoops. Doesn't matter functionally, but probably ought to be consistent.
Comment 4 Robert White 2010-10-14 05:07:55 UTC
Created attachment 250523 [details, diff]
patch to configure data to let package build under gcc 4.5

(Use same operator in both segments to prevent confusion later...)

Patch simply calls "recurse (array)" twice instead of just once in the return statement in the function recurse(char *p). The advanced tail recursion detection in GCC 4.5* will convert the original single-call version of the test into an endless loop.
Comment 5 SpanKY gentoo-dev 2010-10-14 18:40:12 UTC
already in upstream:
http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=91a109c0426e8b8cd8b317e29c8a91bd99757f0a

commit 91a109c0426e8b8cd8b317e29c8a91bd99757f0a
Author: Eric Blake <ebb9@byu.net>
Date:   Tue Sep 23 08:56:10 2008 -0600

    c-stack: avoid compiler optimizations when provoking overflow

    * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Make
    recursion harder to optimize, to ensure a stack overflow occurs.
    * tests/test-c-stack.c (recurse): Likewise.
    Borrowed from libsigsegv.
Comment 6 François Bissey 2011-01-25 22:45:50 UTC
(In reply to comment #5)
> already in upstream:
> http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=91a109c0426e8b8cd8b317e29c8a91bd99757f0a
> 
> commit 91a109c0426e8b8cd8b317e29c8a91bd99757f0a
> Author: Eric Blake <ebb9@byu.net>
> Date:   Tue Sep 23 08:56:10 2008 -0600
> 
>     c-stack: avoid compiler optimizations when provoking overflow
> 
>     * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Make
>     recursion harder to optimize, to ensure a stack overflow occurs.
>     * tests/test-c-stack.c (recurse): Likewise.
>     Borrowed from libsigsegv.
> 
that's 2008. Is the stable version of diffutils in the tree that *old*.
May be a new diffutils should be made stable altogether, this is the only bug returned 
when I searched for diffutils in bugzilla so the 30 days requirement should be fulfilled.
Comment 7 Siarhei Siamashka 2011-01-25 22:59:31 UTC
I have been told that both gcc 4.5 and the fixed diffutils are ~arch keyworded at the moment, so it's not a problem :) They just need to be stabilized at the same time.
Comment 8 Ryan Hill (RETIRED) gentoo-dev 2011-02-06 03:04:21 UTC
> that's 2008. Is the stable version of diffutils in the tree that *old*.
> May be a new diffutils should be made stable altogether, this is the only bug
> returned 
> when I searched for diffutils in bugzilla so the 30 days requirement should be
> fulfilled.

Then file a stabilization bug.
Comment 9 jms 2011-03-20 20:45:48 UTC
(In reply to comment #8)
> > that's 2008. Is the stable version of diffutils in the tree that *old*.
> > May be a new diffutils should be made stable altogether, this is the only bug
> > returned 
> > when I searched for diffutils in bugzilla so the 30 days requirement should be
> > fulfilled.
> 
> Then file a stabilization bug.


well today I had this problem ,I have a stable system (not world) this is anoying.
I am asking to stablize  anew version of diffutils or a pached version of diffutils-2.8.7

the one I have had this problem.
using stable version :sys-apps/diffutils-2.8.7-r2 
after rsync 
Sun Mar 20 16:17:07 VET 2011


no sure how to ask for stabilization (simple user) filled Bug 359657
would like someone to have a look at this.
Comment 10 John M. Drescher 2011-04-13 01:32:09 UTC
I still get an infinite loop in conftest every single time I build sys-apps/diffutils-2.8.7-r2 with gcc-4.5.2. Even in clean metro builds.
Comment 11 mathias.buren 2011-05-01 19:47:14 UTC
(In reply to comment #10)
> I still get an infinite loop in conftest every single time I build
> sys-apps/diffutils-2.8.7-r2 with gcc-4.5.2. Even in clean metro builds.


I'm seeing this as well. sys-apps/diffutils-2.9-r1 is fine though.