[Bug 1333506] [NEW] frexpl math library function is showing wrong output when value slightly smaller than a power of two is passed

Adam Conrad adconrad at 0c3.net
Tue Jun 24 03:35:57 UTC 2014


Public bug reported:

Description:
============
Install a Power 8 machine with Ubuntu LE guest VM.
Then compile and execute the below test case code.

root at ubuntu:~# cat frexpl_example.c
#include <stdio.h>
#include <math.h>

int main(void)
{
  union { long double ld; double d[2]; int i[4]; long long l[2]; } x;
  int expon;

  x.d[0] = 0x1p0;
  x.d[1] = -0x1p-106;
  printf ("%La %13a %13a 0x%16llx 0x%16llx\n",
          x.ld, x.d[0], x.d[1], x.l[0], x.l[1]);
  x.ld = frexpl (x.ld, &expon);
  printf ("%La %13a %13a 0x%16llx 0x%16llx\n",
          x.ld, x.d[0], x.d[1], x.l[0], x.l[1]);
  printf ("expon = %d\n", expon);
  return 0;
}

root at ubuntu:~# gcc frexpl_example.c -lm
root at ubuntu:~# ./a.out
0x1.ffffffffffffffffffffffffff8p-1 0x1p+0 -0x1p-106 0x3ff0000000000000 0xb950000000000000
0x1.ffffffffffffffffffffffffff8p-2 0x1p-1 -0x1p-107 0x3fe0000000000000 0xb940000000000000
expon = 1

root at ubuntu:~# uname -a
Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:09:21 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux
root at ubuntu:~#

root at ubuntu:~# dpkg --list | grep libc6
ii libc6:ppc64el 2.19-0ubuntu6 ppc64el Embedded GNU C Library: Shared libraries
ii libc6-dbg:ppc64el 2.19-0ubuntu6 ppc64el Embedded GNU C Library: detached debugging symbols
ii libc6-dev:ppc64el 2.19-0ubuntu6 ppc64el Embedded GNU C Library: Development Libraries and Header Files
root at ubuntu:~#

The fix is available at the upstream commit:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=aa5f0ff11ad2cc85277c64cf65c723a9664e1149

** Affects: eglibc (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: eglibc (Ubuntu Trusty)
     Importance: Undecided
         Status: New

** Also affects: eglibc (Ubuntu Trusty)
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to eglibc in Ubuntu.
https://bugs.launchpad.net/bugs/1333506

Title:
  frexpl math library function is showing wrong output when value
  slightly smaller than a power of two is passed

Status in “eglibc” package in Ubuntu:
  New
Status in “eglibc” source package in Trusty:
  New

Bug description:
  Description:
  ============
  Install a Power 8 machine with Ubuntu LE guest VM.
  Then compile and execute the below test case code.

  root at ubuntu:~# cat frexpl_example.c
  #include <stdio.h>
  #include <math.h>

  int main(void)
  {
    union { long double ld; double d[2]; int i[4]; long long l[2]; } x;
    int expon;

    x.d[0] = 0x1p0;
    x.d[1] = -0x1p-106;
    printf ("%La %13a %13a 0x%16llx 0x%16llx\n",
            x.ld, x.d[0], x.d[1], x.l[0], x.l[1]);
    x.ld = frexpl (x.ld, &expon);
    printf ("%La %13a %13a 0x%16llx 0x%16llx\n",
            x.ld, x.d[0], x.d[1], x.l[0], x.l[1]);
    printf ("expon = %d\n", expon);
    return 0;
  }

  root at ubuntu:~# gcc frexpl_example.c -lm
  root at ubuntu:~# ./a.out
  0x1.ffffffffffffffffffffffffff8p-1 0x1p+0 -0x1p-106 0x3ff0000000000000 0xb950000000000000
  0x1.ffffffffffffffffffffffffff8p-2 0x1p-1 -0x1p-107 0x3fe0000000000000 0xb940000000000000
  expon = 1

  root at ubuntu:~# uname -a
  Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:09:21 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux
  root at ubuntu:~#

  root at ubuntu:~# dpkg --list | grep libc6
  ii libc6:ppc64el 2.19-0ubuntu6 ppc64el Embedded GNU C Library: Shared libraries
  ii libc6-dbg:ppc64el 2.19-0ubuntu6 ppc64el Embedded GNU C Library: detached debugging symbols
  ii libc6-dev:ppc64el 2.19-0ubuntu6 ppc64el Embedded GNU C Library: Development Libraries and Header Files
  root at ubuntu:~#

  The fix is available at the upstream commit:
  https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=aa5f0ff11ad2cc85277c64cf65c723a9664e1149

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/1333506/+subscriptions



More information about the foundations-bugs mailing list