Subject: bug#13030: closed (Re: bug#13030: factor: infinite loop on Linux/powerpc)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 29 Nov 2012 19:37:02 +0000

Your bug report

#13030: factor: infinite loop on Linux/powerpc

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
13030: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13030
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#13030: factor: infinite loop on Linux/powerpc
From: Pádraig Brady <[email-masked]>
To: Colin Watson <[email-masked]>
Cc: [email-masked], [email-masked], Torbjorn Granlund <[email-masked]>
Date: Thu, 29 Nov 2012 19:34:03 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

On 11/29/2012 02:28 PM, Colin Watson wrote:
> Both Debian and Ubuntu builds of coreutils 8.20 hang while running the
> test suite on powerpc.  This turns out to be reproducible using 'factor
> 122'.
>
> This turns out to be somewhat related to
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12754, but not quite the
> same.  uintmax_t is 64 bits, but the cntlzw instruction takes 32-bit
> operands, and the cntlzd option is only available on 64-bit hardware.  I
> believe the correct answer is to add an _LP64 check around the PPC64
> code, so that this falls back to the C implementations:
>
> --- coreutils-8.20~/src/longlong.h	2012-11-29 14:25:07.000000000 +0000
> +++ coreutils-8.20/src/longlong.h	2012-11-29 14:26:40.000000000 +0000
> @@ -1398,7 +1398,7 @@
>
>   /* We should test _IBMR2 here when we add assembly support for the system
>      vendor compilers.  */
> -#if HAVE_HOST_CPU_FAMILY_powerpc && W_TYPE_SIZE == 64
> +#if HAVE_HOST_CPU_FAMILY_powerpc && W_TYPE_SIZE == 64 && defined (_LP64)
>   #if !defined (_LONG_LONG_LIMB)
>   /* _LONG_LONG_LIMB is ABI=mode32 where adde operates on 32-bit values.  So
>      use adde etc only when not _LONG_LONG_LIMB.  */
>
> Thanks,
>

The fix looks good thanks.
I'll commit that in your name along with this NEWS entry:

** Bug fixes

   factor no longer hangs on 32 bit powerpc systems.
   [bug introduced in coreutil-8.20]

thanks,
Pádraig.

Subject: factor: infinite loop on Linux/powerpc
From: Colin Watson <[email-masked]>
To: [email-masked]
Date: Thu, 29 Nov 2012 14:28:18 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Both Debian and Ubuntu builds of coreutils 8.20 hang while running the
test suite on powerpc.  This turns out to be reproducible using 'factor
122'.

This turns out to be somewhat related to
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12754, but not quite the
same.  uintmax_t is 64 bits, but the cntlzw instruction takes 32-bit
operands, and the cntlzd option is only available on 64-bit hardware.  I
believe the correct answer is to add an _LP64 check around the PPC64
code, so that this falls back to the C implementations:

--- coreutils-8.20~/src/longlong.h	2012-11-29 14:25:07.000000000 +0000
+++ coreutils-8.20/src/longlong.h	2012-11-29 14:26:40.000000000 +0000
@@ -1398,7 +1398,7 @@
 
 /* We should test _IBMR2 here when we add assembly support for the system
    vendor compilers.  */
-#if HAVE_HOST_CPU_FAMILY_powerpc && W_TYPE_SIZE == 64
+#if HAVE_HOST_CPU_FAMILY_powerpc && W_TYPE_SIZE == 64 && defined (_LP64)
 #if !defined (_LONG_LONG_LIMB)
 /* _LONG_LONG_LIMB is ABI=mode32 where adde operates on 32-bit values.  So
    use adde etc only when not _LONG_LONG_LIMB.  */

Thanks,

-- 
Colin Watson                                       [[email-masked]]