Open k0stjap opened 4 years ago
Sorry to not have responded to this earlier, and thanks for the report. Unfortunately, I will not be able to look into this in the near future, but I just wanted to tell you that it is not ignored and I will look into it.
If one runs the program attached below, valgrind reports the data associated with the 'rndLocal' object as 'definitely lost'.
Unfortunately I do not have the time to scan the issue thoroughly, but it looks like the ViewSelRnd object - created on gecode-managed "space" memory arena - retains a shared 'Rnd' handle but the Rnd's destructor - which would take care of managing the shared handle the right way - is never executed (because, apparently - and very understandably - the "space" memory area is "bulk-discarded).
/* g++ -o bug5 =1/bug5.cpp -L/usr/local/lib -lgecodekernel -lgecodesupport -lgecodeint -lgecodesearch g++ -ggdb -o bug5 =1/bug5.cpp -L/usr/local/lib -lgecodekernel -lgecodesupport -lgecodeint -lgecodesearch setenv LD_LIBRARY_PATH /usr/local/lib ./branching0 valgrind -s --leak-check=full --track-origins=yes --read-var-info=yes ./bug5
*/
include <gecode/int.hh>
include <gecode/search.hh>
using namespace Gecode;
Rnd rndGlobal(0);
class VarsSpace : public Space { protected: IntVarArray vars; public: VarsSpace(void) : vars(this, 2, 0, 0) {} void branchRnd(Rnd &rnd) { branch(this, vars, INT_VAR_RND(rnd), INT_VAL_MIN()); } VarsSpace(VarsSpace& s) : Space(s) { vars.update(this, s.vars); } virtual Space copy(void) { return new VarsSpace(*this); } };
// main function int main(int argc, char argv[]) { Rnd rndLocal(0); // create model and search engine VarsSpace m = new VarsSpace; // m->branchRnd(rndGlobal); m->branchRnd(rndLocal); DFS e(m);
delete m;
VarsSpace* s = e.next();
delete s;
return (0);
}