Gecode / gecode

Generic Constraint Development Environment
https://www.gecode.org
Other
283 stars 76 forks source link

Or-ing of booleans with BoolExpr causes SEGV #139

Open yurivict opened 2 years ago

yurivict commented 2 years ago

Describe the bug

This code pattern:

  BoolExpr sum;
  sum = sum || (var1 && var2);
  sum = sum || (var3 && var4);
  rel(*this, sum);

always causes crash:

Program received signal SIGSEGV, Segmentation fault.
Address not mapped to object.
0x0000000800db2247 in ?? () from /usr/local/lib/libgecodeminimodel.so.51
(gdb) bt
#0  0x0000000800db2247 in ?? () from /usr/local/lib/libgecodeminimodel.so.51
#1  0x0000000800db2384 in ?? () from /usr/local/lib/libgecodeminimodel.so.51
#2  0x0000000800db2384 in ?? () from /usr/local/lib/libgecodeminimodel.so.51
#3  0x0000000800db2384 in ?? () from /usr/local/lib/libgecodeminimodel.so.51
#4  0x0000000800db2e1e in Gecode::BoolExpr::rel(Gecode::Home, Gecode::IntPropLevels const&) const () from /usr/local/lib/libgecodeminimodel.so.51
#5  0x0000000800db3ee1 in Gecode::rel(Gecode::Home, Gecode::BoolExpr const&, Gecode::IntPropLevels const&) () from /usr/local/lib/libgecodeminimodel.so.51

But this code succeeds:

  BoolExpr sum;
  sum = (var1 && var2);
  sum = sum || (var3 && var4);
  rel(*this, sum);

BoolExpr doesn't seem to accept a boolean initializer, like LinIntExpr accepts an integer initializer.

Is boolean initialization forgotten, or what might be a solution?

sirwhinesalot commented 1 year ago

Late reply @yurivict but I work around this by adding auto TRUE = BoolVar(home, 1, 1) and FALSE = BoolVar(home, 0, 0) to my model. They really should be built-in though I agree.