Skip to content

Commit 9fd7dd4

Browse files
author
svorenova
authored
Merge pull request #4643 from svorenova/max-nondet-string-length-default
Set max-nondet-string-length to 10000 by default
2 parents c3fff98 + 15e5493 commit 9fd7dd4

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
CORE
22
Test.class
3-
--function Test.check
3+
--function Test.check --max-nondet-string-length 1000000000
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
77
file Test.java line 20 .*: FAILURE$
88
--
99
--
10-
--max-nondet-string-length is not used on purpose, because this tests the behaviour
11-
of string refinement on very large strings.
10+
This tests the behaviour of string refinement on very large strings.
11+
max-nondet-string-length is set big enough to cause an overflow.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
CORE
22
Test.class
3-
--function Test.checkAbort --trace
3+
--function Test.checkAbort --trace --max-nondet-string-length 1000000000
44
^EXIT=10$
55
^SIGNAL=0$
66
dynamic_object[0-9]*=\(assignment removed\)
77
--
88
--
99
This tests that the object does not appear in the trace, because concretizing
1010
a string of the required length may take too much memory.
11+
max-nondet-string-length is set big enough to cause an overflow.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
Test.class
3-
--function Test.checkMinLength --string-non-empty
3+
--function Test.checkMinLength --string-non-empty --max-nondet-string-length 2000000000
44
^EXIT=10$
55
^SIGNAL=0$
66
assertion.* line 11 function java::Test.checkMinLength.*: SUCCESS
@@ -9,3 +9,5 @@ assertion.* line 17 function java::Test.checkMinLength.*: FAILURE
99
assertion.* line 19 function java::Test.checkMinLength.*: FAILURE
1010
--
1111
^Building error trace
12+
--
13+
max-nondet-string-length is set big enough to cause an overflow.

src/solvers/strings/string_refinement.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Author: Alberto Griggio, [email protected]
2121
#define CPROVER_SOLVERS_REFINEMENT_STRING_REFINEMENT_H
2222

2323
#include <limits>
24+
#include <util/magic.h>
2425
#include <util/replace_expr.h>
2526
#include <util/string_expr.h>
2627
#include <util/union_find_replace.h>
@@ -45,7 +46,8 @@ Author: Alberto Griggio, [email protected]
4546
" --string-input-value st restrict non-null strings to a fixed value st;\n" /* NOLINT(*) */ \
4647
" the switch can be used multiple times to give\n" /* NOLINT(*) */ \
4748
" several strings\n" /* NOLINT(*) */ \
48-
" --max-nondet-string-length n bound the length of nondet (e.g. input) strings\n" /* NOLINT(*) */
49+
" --max-nondet-string-length n bound the length of nondet (e.g. input) strings;\n" /* NOLINT(*) */ \
50+
" set to " + std::to_string(MAX_NONDET_STRING_LENGTH_DEFAULT) + " by default\n" /* NOLINT(*) */
4951

5052
// The integration of the string solver into CBMC is incomplete. Therefore,
5153
// it is not turned on by default and not all options are available.

src/util/magic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ const std::size_t MAX_CONCRETE_STRING_SIZE = 1 << 26;
1616
// The top end of the range of integers for which dstrings are precomputed
1717
constexpr std::size_t DSTRING_NUMBERS_MAX = 64;
1818

19+
const int MAX_NONDET_STRING_LENGTH_DEFAULT = 10000;
20+
1921
#endif

src/util/object_factory_parameters.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Author: Diffblue Ltd
88

99
#include "object_factory_parameters.h"
1010

11-
#include <util/cmdline.h>
12-
#include <util/options.h>
11+
#include "cmdline.h"
12+
#include "magic.h"
13+
#include "options.h"
1314

1415
void object_factory_parameterst::set(const optionst &options)
1516
{
@@ -68,12 +69,19 @@ void parse_object_factory_options(const cmdlinet &cmdline, optionst &options)
6869
options.set_option(
6970
"min-null-tree-depth", cmdline.get_value("min-null-tree-depth"));
7071
}
72+
7173
if(cmdline.isset("max-nondet-string-length"))
7274
{
7375
options.set_option(
7476
"max-nondet-string-length",
7577
cmdline.get_value("max-nondet-string-length"));
7678
}
79+
else if(!cmdline.isset("no-refine-strings"))
80+
{
81+
options.set_option(
82+
"max-nondet-string-length", MAX_NONDET_STRING_LENGTH_DEFAULT);
83+
}
84+
7785
if(cmdline.isset("string-printable"))
7886
{
7987
options.set_option("string-printable", true);

0 commit comments

Comments
 (0)