TypeNode typeNode = TypeNode::fromType(type);
NodeManager* to_nm = NodeManager::fromExprManager(to);
Node n = to_nm->mkBoundVar(name, typeNode); // FIXME thread safety
+
+ // Make sure that the correct `NodeManager` is in scope while
+ // converting the node to an expression.
+ NodeManagerScope to_nms(to_nm);
to_e = n.toExpr();
} else if(n.getKind() == kind::VARIABLE) {
bool isGlobal;
TypeNode typeNode = TypeNode::fromType(type);
NodeManager* to_nm = NodeManager::fromExprManager(to);
Node n = to_nm->mkSkolem(name, typeNode, "is a skolem variable imported from another ExprManager");// FIXME thread safety
+
+ // Make sure that the correct `NodeManager` is in scope while
+ // converting the node to an expression.
+ NodeManagerScope to_nms(to_nm);
to_e = n.toExpr();
} else {
Unhandled();
TypeNode typeNode = TypeNode::fromType(type);
NodeManager* to_nm = NodeManager::fromExprManager(to);
Node n = to_nm->mkBoundVar(typeNode); // FIXME thread safety
+
+ // Make sure that the correct `NodeManager` is in scope while
+ // converting the node to an expression.
+ NodeManagerScope to_nms(to_nm);
to_e = n.toExpr();
}
else
vmap.d_from[to_int] = from_int;
vmap.d_to[from_int] = to_int;
vmap.d_typeMap[to_e] = from_e;// insert other direction too
+
+ // Make sure that the expressions are associated with the correct
+ // `ExprManager`s.
+ Assert(from_e.getExprManager() == from);
+ Assert(to_e.getExprManager() == to);
return Node::fromExpr(to_e);
}
} else {
Debug("gc") << (d_inReclaimZombies ? " [CURRENTLY-RECLAIMING]" : "")
<< std::endl;
}
+
+ // `d_zombies` uses the node id to hash and compare nodes. If `d_zombies`
+ // already contains a node value with the same id as `nv`, but the pointers
+ // are different, then the wrong `NodeManager` was in scope for one of the
+ // two nodes when it reached refcount zero. This can happen for example if
+ // you create a node with a `NodeManager` n1 and then call `Node::toExpr()`
+ // on that node while a different `NodeManager` n2 is in scope. When that
+ // `Expr` is deleted and the node reaches refcount zero in the `Expr`'s
+ // destructor, then `markForDeletion()` will be called on n2.
+ Assert(d_zombies.find(nv) == d_zombies.end() || *d_zombies.find(nv) == nv);
+
d_zombies.insert(nv); // FIXME multithreading
if(safeToReclaimZombies()) {
// options as the SmtEngine we belong to, where we ensure that
// produce-models is set.
bool needExport = false;
- ExprManagerMapCollection varMap;
ExprManager em(nm->getOptions());
std::unique_ptr<SmtEngine> rrChecker;
+ ExprManagerMapCollection varMap;
initializeChecker(rrChecker, em, varMap, crr, needExport);
Result r = rrChecker->checkSat();
Trace("rr-check") << "...result : " << r << std::endl;
}
NodeManager* nm = NodeManager::currentNM();
bool needExport = false;
- ExprManagerMapCollection varMap;
ExprManager em(nm->getOptions());
std::unique_ptr<SmtEngine> smte;
+ ExprManagerMapCollection varMap;
initializeChecker(smte, em, varMap, queryr, needExport);
return smte->checkSat();
}
NodeManager* nm = NodeManager::currentNM();
// make the satisfiability query
bool needExport = false;
- ExprManagerMapCollection varMap;
ExprManager em(nm->getOptions());
std::unique_ptr<SmtEngine> queryChecker;
+ ExprManagerMapCollection varMap;
initializeChecker(queryChecker, em, varMap, qy, needExport);
Result r = queryChecker->checkSat();
Trace("sygus-qgen-check") << " query: ...got : " << r << std::endl;
-; REQUIRES: no-asan
; COMMAND-LINE: --sygus-rr --sygus-samples=1000 --sygus-abort-size=2 --sygus-rr-verify-abort --no-sygus-sym-break
; COMMAND-LINE: --sygus-rr-synth --sygus-samples=1000 --sygus-abort-size=2 --sygus-rr-verify-abort --sygus-rr-synth-check
; EXPECT: (error "Maximum term size (2) for enumerative SyGuS exceeded.")
-; REQUIRES: no-asan
; REQUIRES: symfpu
; COMMAND-LINE: --sygus-rr --sygus-samples=0 --sygus-rr-synth-check --sygus-abort-size=1 --sygus-rr-verify-abort --no-sygus-sym-break
; EXPECT: (error "Maximum term size (1) for enumerative SyGuS exceeded.")
-; REQUIRES: no-asan
; REQUIRES: symfpu
; COMMAND-LINE: --sygus-rr --sygus-samples=0 --sygus-rr-synth-check --sygus-abort-size=1 --sygus-rr-verify-abort --no-sygus-sym-break
; EXPECT: (error "Maximum term size (1) for enumerative SyGuS exceeded.")