Package: valgrind
Version: 1:3.13.0-2
Severity: important

valgrind causes miscalculation on the following program:

----------------------------------------
#include <stdio.h>

int main (void)
{
  volatile union {
    long double d;
    unsigned long i[2];
  } u;

  u.i[0] = 1;
  u.i[1] = 0;
  printf ("%La\n", u.d);

  return 0;
}
----------------------------------------

zira:~> gcc tst.c -o tst
zira:~> ./tst
0x0.000000000000001p-16385
zira:~> valgrind ./tst
==3567== Memcheck, a memory error detector
==3567== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3567== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==3567== Command: ./tst
==3567== 
0x0p+0
==3567== 
==3567== HEAP SUMMARY:
==3567==     in use at exit: 0 bytes in 0 blocks
==3567==   total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==3567== 
==3567== All heap blocks were freed -- no leaks are possible
==3567== 
==3567== For counts of detected and suppressed errors, rerun with: -v
==3567== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Instead of 0x0.000000000000001p-16385, one gets 0.

Bug found with MPFR: the tset_ld test fails with valgrind for this
reason.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 
'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.14.0-3-amd64 (SMP w/8 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=POSIX 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages valgrind depends on:
ii  libc6      2.26-6
ii  libc6-dbg  2.26-6

Versions of packages valgrind recommends:
ii  gdb           7.12-6+b1
ii  valgrind-dbg  1:3.13.0-2

Versions of packages valgrind suggests:
pn  alleyoop      <none>
pn  kcachegrind   <none>
pn  valgrind-mpi  <none>
pn  valkyrie      <none>

-- no debconf information

Reply via email to