codac icon indicating copy to clipboard operation
codac copied to clipboard

Bug with valgrind (rounding mode?)

Open SimonRohou opened this issue 1 year ago • 1 comments

The debugger creates a bug... The following code:

  Interval x(-3,-0.0599999427795410086861060960927716223523);
  Interval x_save(x);
  Interval m = -2.15;
  Interval p = x-m;
  x &= p+m;
  cout << setprecision(40) << x_save << endl;
  cout << setprecision(40) << x << endl;
  cout << "is_strict_subset: " << x.is_strict_subset(x_save) << endl;

provides, without valgrind:

[-3, -0.059999942779541]
[-3, -0.059999942779541]
is_strict_subset: 0

and with valgrind:

==62032== Memcheck, a memory error detector
==62032== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==62032== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==62032== Command: ./codac_example
==62032== 
[-3, -0.059999942779541]
[-3, -0.05999994277954101]
is_strict_subset: 1
==62032== 
==62032== HEAP SUMMARY:
==62032==     in use at exit: 0 bytes in 0 blocks
==62032==   total heap usage: 4 allocs, 4 frees, 74,784 bytes allocated
==62032== 
==62032== All heap blocks were freed -- no leaks are possible
==62032== 
==62032== For lists of detected and suppressed errors, rerun with: -s
==62032== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Using valgrind, the interval x is contracted after the operation, that should not have any effect.

The bug appears using either GAOL or Filib. This is probably due to some rouding modes operated by valgrind.

SimonRohou avatar Jun 18 '24 15:06 SimonRohou

Quite likely a Valgrind limitation. There are numerous issues with floating point in Valgrind (no Avx512 no x87 no FPE and there are rounding mode issues on some platforms).

Could you look at bugs.kde.org and see if any existing bugs correspond? And if not open a new one?

paulfloyd avatar Jun 22 '24 04:06 paulfloyd