codac-team / codac

Codac is a library for constraint programming over reals, trajectories and sets.
http://www.codac.io
GNU Lesser General Public License v3.0
39 stars 18 forks source link

Bug with valgrind (rounding mode?) #113

Open SimonRohou opened 3 months ago

SimonRohou commented 3 months ago

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.

paulfloyd commented 3 months ago

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?