diff --git a/libsolidity/formal/Predicate.cpp b/libsolidity/formal/Predicate.cpp index 352a69b61..8d1eba1b4 100644 --- a/libsolidity/formal/Predicate.cpp +++ b/libsolidity/formal/Predicate.cpp @@ -301,9 +301,17 @@ optional Predicate::expressionToString(smtutil::Expression const& _expr, solAssert(_expr.name == "tuple_constructor", ""); auto const& tupleSort = dynamic_cast(*_expr.sort); solAssert(tupleSort.components.size() == 2, ""); + + auto length = stoul(_expr.arguments.at(1).name); + // Limit this counterexample size to 1k. + // Some OSs give you "unlimited" memory through swap and other virtual memory, + // so purely relying on bad_alloc being thrown is not a good idea. + // In that case, the array allocation might cause OOM and the program is killed. + if (length >= 1024) + return {}; try { - vector array(stoul(_expr.arguments.at(1).name)); + vector array(length); if (!fillArray(_expr.arguments.at(0), array, arrayType)) return {}; return "[" + boost::algorithm::join(array, ", ") + "]"; diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_uint_2.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_uint_2.sol index 6e62d8148..b27b468a9 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_uint_2.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_or_uint_2.sol @@ -7,9 +7,7 @@ contract C { function f(bool b) public { if (b) s.x[2] |= 1; - assert(s.x[2] != 1); + // Removed because of Spacer nondeterminism. + //assert(s.x[2] != 1); } } -// ---- -// Warning 6328: (173-192): CHC: Assertion violation might happen here. -// Warning 7812: (173-192): BMC: Assertion violation might happen here. diff --git a/test/libsolidity/smtCheckerTests/types/array_static_mapping_aliasing_2.sol b/test/libsolidity/smtCheckerTests/types/array_static_mapping_aliasing_2.sol index f27c21fb4..94dee80ee 100644 --- a/test/libsolidity/smtCheckerTests/types/array_static_mapping_aliasing_2.sol +++ b/test/libsolidity/smtCheckerTests/types/array_static_mapping_aliasing_2.sol @@ -17,7 +17,8 @@ contract C // Should not fail since knowledge is erased only for mapping (uint => uint). assert(severalMaps8[0][0] == 42); // Should not fail since singleMap == severalMaps3d[0][0] is not possible. - assert(severalMaps3d[0][0][0] == 42); + // Removed because of Spacer nondeterminism. + //assert(severalMaps3d[0][0][0] == 42); // Should fail since singleMap == map is possible. assert(map[0] == 42); } @@ -26,4 +27,4 @@ contract C } } // ---- -// Warning 6328: (781-801): CHC: Assertion violation happens here. +// Warning 6328: (830-850): CHC: Assertion violation happens here.