Skip to content

Commit 56e7b37

Browse files
Make get_array return nil for long strings
Instead of aborting the program when the string is too long, we consider this happened because of some invalid object, and return nil as a model of the array. Access to this invalid object is prevented by other part of the code and should not occur in the trace.
1 parent 5fde05a commit 56e7b37

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
CORE
22
Test.class
3-
--refine-strings --function Test.checkAbort
4-
^EXIT=6$
3+
--refine-strings --function Test.checkAbort --trace
4+
^EXIT=10$
55
^SIGNAL=0$
6+
dynamic_object[0-9]*=\(assignment removed\)
67
--
78
--
8-
This tests should abort, because concretizing a string of the required
9-
length may take to much memory.
9+
This tests that the object does not appear in the trace, because concretizing
10+
a string of the required length may take too much memory.

src/solvers/refinement/string_refinement.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -933,12 +933,17 @@ static optionalt<exprt> get_array(
933933

934934
if(n > MAX_CONCRETE_STRING_SIZE)
935935
{
936-
stream << "(sr::get_array) long string (size=" << n << ")" << eom;
937-
std::ostringstream msg;
938-
msg << "consider reducing string-max-input-length so that no string "
939-
<< "exceeds " << MAX_CONCRETE_STRING_SIZE << " in length and make sure"
940-
<< " all functions returning strings are available in the classpath";
941-
throw string_refinement_invariantt(msg.str());
936+
stream << "(sr::get_array) long string (size " << format(arr.length())
937+
<< " = " << n << ") " << format(arr) << eom;
938+
stream << "(sr::get_array) consider reducing string-max-input-length so "
939+
"that no string exceeds "
940+
<< MAX_CONCRETE_STRING_SIZE
941+
<< " in length and "
942+
"make sure all functions returning strings are loaded"
943+
<< eom;
944+
stream << "(sr::get_array) this can also happen on invalid object access"
945+
<< eom;
946+
return nil_exprt();
942947
}
943948

944949
if(

0 commit comments

Comments
 (0)