Bug#855606: sqrt() regression on powerpc/jessie

2017-02-20 Thread Christoph Berg
Package: libc6
Version: 2.19-18+deb8u7
Severity: normal
Tags: jessie

The following C program produces different output on Jessie and Sid. I
believe the Sid output is the correct one, and in fact this is the
output that has been observed for the "point" (and "polygon")
regression tests for PostgreSQL on all platforms for the last 20 years
since the test got added.


$ cat sqrt.c
#include 
#include 
#include 

double
pg_hypot(double x, double y)
{
double  yx;

/* Some PG-specific code deleted here */

/* Else, drop any minus signs */
x = fabs(x);
y = fabs(y);

/* Swap x and y if needed to make x the larger one */
if (x < y)
{
double  temp = x;

x = y;
y = temp;
}

/*
 * If y is zero, the hypotenuse is x.  This test saves a few cycles in
 * such cases, but more importantly it also protects against
 * divide-by-zero errors, since now x >= y.
 */
if (y == 0.0)
return x;

/* Determine the hypotenuse */
yx = y / x;
return x * sqrt(1.0 + (yx * yx));
}


int main ()
{
//fesetround(FE_TONEAREST);
printf("fegetround is %d\n", fegetround());
double r = pg_hypot(10.0, 10.0);
printf("14 %.14g\n", r);
printf("15 %.15g\n", r);
printf("16 %.16g\n", r);
printf("17 %.17g\n", r);
return 0;
}


Jessie output:
fegetround is 0
14 14.142135623731
15 14.1421356237309
16 14.14213562373095
17 14.142135623730949

Sid output:
fegetround is 0
14 14.142135623731
15 14.142135623731
16 14.14213562373095
17 14.142135623730951


The Sid output is also observed when running the binary compiled on
Jessie on Sid, so it's a library issue, not a compiler/binary one.


The problem might be due to the fix for #843904.


FTBFS in postgresql-9.4 in jessie-pu:
https://buildd.debian.org/status/fetch.php?pkg=postgresql-9.4=powerpc=9.4.11-0%2Bdeb8u1=1487473754=0
FTBFS in postgresql-9.6 in jessie-backports:
https://buildd.debian.org/status/fetch.php?pkg=postgresql-9.6=powerpc=9.6.1-2~bpo8%2B1=1485184696=0

Thread on pgsql-hackers:
https://www.postgresql.org/message-id/20170220155819.m2s43pf2pvkes4pc%40msg.credativ.de

Christoph


signature.asc
Description: PGP signature


Processed: affects 855606

2017-02-20 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> affects 855606 + release.debian.org
Bug #855606 [libc6] sqrt() regression on powerpc/jessie
Added indication that 855606 affects release.debian.org
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
855606: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855606
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



[glibc] 01/01: Update from upstream stable branch:

2017-02-20 Thread Aurelien Jarno
This is an automated email from the git hooks/post-receive script.

aurel32 pushed a commit to branch jessie
in repository glibc.

commit b26c084f6eba0057b1cd93e0caf424a1d06bd97e
Author: Aurelien Jarno 
Date:   Mon Feb 20 23:32:25 2017 +0100

Update from upstream stable branch:

* Update from upstream stable branch:
  - Fix PowerPC sqrt inaccuracy.  Closes: #855606.
---
 debian/changelog|  8 +
 debian/patches/git-updates.diff | 79 -
 2 files changed, 79 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index fdbdcc3..ffbd139 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+glibc (2.19-18+deb8u8) UNRELEASED; urgency=medium
+
+  [ Aurelien Jarno ]
+  * Update from upstream stable branch:
+- Fix PowerPC sqrt inaccuracy.  Closes: #855606.
+
+ -- Aurelien Jarno   Mon, 20 Feb 2017 23:30:47 +0100
+
 glibc (2.19-18+deb8u7) stable; urgency=medium
 
   [ Aurelien Jarno ]
diff --git a/debian/patches/git-updates.diff b/debian/patches/git-updates.diff
index 5e3d836..c39df17 100644
--- a/debian/patches/git-updates.diff
+++ b/debian/patches/git-updates.diff
@@ -1,10 +1,16 @@
 GIT update of git://sourceware.org/git/glibc.git/release/2.19/master from 
glibc-2.19
 
 diff --git a/ChangeLog b/ChangeLog
-index 81c393a..92b8a2e 100644
+index 81c393a..a81d623 100644
 --- a/ChangeLog
 +++ b/ChangeLog
-@@ -1,3 +1,639 @@
+@@ -1,3 +1,645 @@
++2015-02-12  Joseph Myers  
++
++  [BZ #17964]
++  * sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrt): Use
++  __builtin_fma instead of relying on contraction of a * b + c.
++
 +2015-01-28  Adhemerval Zanellla  
 +
 +  [BZ #16576]
@@ -645,7 +651,7 @@ index 81c393a..92b8a2e 100644
  
[BZ #16529]
 diff --git a/NEWS b/NEWS
-index 98b479e..f62b876 100644
+index 98b479e..bdbf52b 100644
 --- a/NEWS
 +++ b/NEWS
 @@ -5,6 +5,104 @@ See the end for copying conditions.
@@ -659,8 +665,8 @@ index 98b479e..f62b876 100644
 +  15946, 16009, 16545, 16574, 16576, 16623, 16657, 16695, 16743, 16758,
 +  16759, 16760, 16878, 16882, 16885, 16916, 16932, 16943, 16958, 17048,
 +  17062, 17069, 17079, 17137, 17153, 17213, 17263, 17269, 17325, 17523,
-+  17555, 17905, 18007, 18032, 18080, 18240, 18287, 18508, 18665, 18905,
-+  18928, 19018, 19779, 19791, 19879, 20010, 20112.
++  17555, 17905, 17964, 18007, 18032, 18080, 18240, 18287, 18508, 18665,
++  18905, 18928, 19018, 19779, 19791, 19879, 20010, 20112.
 +
 +* A buffer overflow in gethostbyname_r and related functions performing DNS
 +  requests has been fixed.  If the NSS functions were called with a
@@ -6539,7 +6545,7 @@ index 64d192a..4b7ec36 100644
va_list arg;
va_start (arg, oflag);
 diff --git a/sysdeps/powerpc/fpu/e_sqrt.c b/sysdeps/powerpc/fpu/e_sqrt.c
-index 0368e57..24dfe68 100644
+index 0368e57..022d71b 100644
 --- a/sysdeps/powerpc/fpu/e_sqrt.c
 +++ b/sysdeps/powerpc/fpu/e_sqrt.c
 @@ -24,6 +24,7 @@
@@ -6550,7 +6556,64 @@ index 0368e57..24dfe68 100644
  static const double almost_half = 0.5001; /* 0.5 + 2^-53 */
  static const ieee_float_shape_type a_nan = {.word = 0x7fc0 };
  static const ieee_float_shape_type a_inf = {.word = 0x7f80 };
-@@ -152,6 +153,7 @@ __slow_ieee754_sqrt (double x)
+@@ -98,38 +99,41 @@ __slow_ieee754_sqrt (double x)
+ /* Here we have three Newton-Raphson iterations each of a
+division and a square root and the remainder of the
+argument reduction, all interleaved.   */
+-sd = -(sg * sg - sx);
++sd = -__builtin_fma (sg, sg, -sx);
+ fsgi = (xi0 + 0x4000) >> 1 & 0x7ff0;
+ sy2 = sy + sy;
+-sg = sy * sd + sg;/* 16-bit approximation to sqrt(sx). */
++sg = __builtin_fma (sy, sd, sg);  /* 16-bit approximation to
++ sqrt(sx). */
+ 
+ /* schedule the INSERT_WORDS (fsg, fsgi, 0) to get separation
+between the store and the load.  */
+ INSERT_WORDS (fsg, fsgi, 0);
+ iw_u.parts.msw = fsgi;
+ iw_u.parts.lsw = (0);
+-e = -(sy * sg - almost_half);
+-sd = -(sg * sg - sx);
++e = -__builtin_fma (sy, sg, -almost_half);
++sd = -__builtin_fma (sg, sg, -sx);
+ if ((xi0 & 0x7ff0) == 0)
+   goto denorm;
+-sy = sy + e * sy2;
+-sg = sg + sy * sd;/* 32-bit approximation to sqrt(sx).  */
++sy = __builtin_fma (e, sy2, sy);
++sg = __builtin_fma (sy, sd, sg);  /* 32-bit approximation to
++ sqrt(sx).  */
+ sy2 = sy + sy;
+ /* complete the INSERT_WORDS (fsg, fsgi, 0) operation.  */
+ fsg = iw_u.value;
+-e = -(sy * sg - almost_half);
+-sd = -(sg * sg - sx);
+-sy = sy + e * sy2;
++e = -__builtin_fma (sy, 

[glibc] branch jessie updated (f8b6cd8 -> b26c084)

2017-02-20 Thread Aurelien Jarno
This is an automated email from the git hooks/post-receive script.

aurel32 pushed a change to branch jessie
in repository glibc.

  from  f8b6cd8   releasing package glibc version 2.19-18+deb8u7
   new  b26c084   Update from upstream stable branch:

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 debian/changelog|  8 +
 debian/patches/git-updates.diff | 79 -
 2 files changed, 79 insertions(+), 8 deletions(-)

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-glibc/glibc.git



Processed: Bug#855606 marked as pending

2017-02-20 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> tag 855606 pending
Bug #855606 [libc6] sqrt() regression on powerpc/jessie
Added tag(s) pending.
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
855606: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855606
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems