-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1235 from romainbrenguier/feature/string-max-inpu…
…t-length#948 String max input length option
- Loading branch information
Showing
18 changed files
with
173 additions
and
107 deletions.
There are no files selected for viewing
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
regression/strings-smoke-tests/max_input_length/MemberTest.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
MemberTest.class | ||
--refine-strings --string-max-length 29 --java-assume-inputs-non-null | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- |
9 changes: 9 additions & 0 deletions
9
regression/strings-smoke-tests/max_input_length/MemberTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
public class MemberTest { | ||
String foo; | ||
public void main() { | ||
// Causes this function to be ignored if string-max-length is | ||
// less than 40 | ||
String t = new String("0123456789012345678901234567890123456789"); | ||
assert foo != null && foo.length() < 30; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
public class Test { | ||
public static void main(String s) { | ||
// This prevent anything from happening if string-max-length is smaller | ||
// than 40 | ||
String t = new String("0123456789012345678901234567890123456789"); | ||
if (s.length() >= 30) | ||
// This should not happen when string-max-input length is smaller | ||
// than 30 | ||
assert false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
Test.class | ||
--refine-strings --string-max-length 30 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
Test.class | ||
--refine-strings --string-max-length 45 --string-max-input-length 31 | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
Test.class | ||
--refine-strings --string-max-length 45 --string-max-input-length 20 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ Author: Daniel Kroening, [email protected] | |
" A '.*' wildcard is allowed to specify all class members\n" | ||
|
||
#define MAX_NONDET_ARRAY_LENGTH_DEFAULT 5 | ||
#define MAX_NONDET_STRING_LENGTH std::numeric_limits<std::int32_t>::max() | ||
#define MAX_NONDET_TREE_DEPTH 5 | ||
|
||
class symbolt; | ||
|
@@ -59,6 +60,23 @@ enum lazy_methods_modet | |
LAZY_METHODS_MODE_CONTEXT_SENSITIVE | ||
}; | ||
|
||
struct object_factory_parameterst final | ||
{ | ||
/// Maximum value for the non-deterministically-chosen length of an array. | ||
size_t max_nondet_array_length=MAX_NONDET_ARRAY_LENGTH_DEFAULT; | ||
|
||
/// Maximum value for the non-deterministically-chosen length of a string. | ||
size_t max_nondet_string_length=MAX_NONDET_STRING_LENGTH; | ||
|
||
/// Maximum depth for object hierarchy on input. | ||
/// Used to prevent object factory to loop infinitely during the | ||
/// generation of code that allocates/initializes data structures of recursive | ||
/// data types or unbounded depth. We bound the maximum number of times we | ||
/// dereference a pointer using a 'depth counter'. We set a pointer to null if | ||
/// such depth becomes >= than this maximum value. | ||
size_t max_nondet_tree_depth=MAX_NONDET_TREE_DEPTH; | ||
}; | ||
|
||
typedef std::pair< | ||
const symbolt *, | ||
const java_bytecode_parse_treet::methodt *> | ||
|
@@ -95,8 +113,7 @@ class java_bytecode_languaget:public languaget | |
java_bytecode_languaget( | ||
std::unique_ptr<select_pointer_typet> pointer_type_selector): | ||
assume_inputs_non_null(false), | ||
max_nondet_array_length(MAX_NONDET_ARRAY_LENGTH_DEFAULT), | ||
max_nondet_tree_depth(MAX_NONDET_TREE_DEPTH), | ||
object_factory_parameters(), | ||
max_user_array_length(0), | ||
lazy_methods_mode(lazy_methods_modet::LAZY_METHODS_MODE_EAGER), | ||
string_refinement_enabled(false), | ||
|
@@ -149,8 +166,7 @@ class java_bytecode_languaget:public languaget | |
std::vector<irep_idt> main_jar_classes; | ||
java_class_loadert java_class_loader; | ||
bool assume_inputs_non_null; // assume inputs variables to be non-null | ||
size_t max_nondet_array_length; // maximal length for non-det array creation | ||
size_t max_nondet_tree_depth; // maximal depth for object tree in non-det creation | ||
object_factory_parameterst object_factory_parameters; | ||
size_t max_user_array_length; // max size for user code created arrays | ||
lazy_methodst lazy_methods; | ||
lazy_methods_modet lazy_methods_mode; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.