gecode icon indicating copy to clipboard operation
gecode copied to clipboard

Or-ing of booleans with BoolExpr causes SEGV

Open yurivict opened this issue 3 years ago • 1 comments

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?

yurivict avatar Dec 18 '21 00:12 yurivict

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.

sirwhinesalot avatar Jun 29 '23 11:06 sirwhinesalot