Skip to content

Commit

Permalink
Fix for csmith hanging with these arguments:
Browse files Browse the repository at this point in the history
csmith --lang-cpp --seed 3168423516

csmith has a limit on pointer levels; default was 2.
This limit was respected in one place and not respected in another.
Enforce the limit. Up the default to 5 as a good compromise between 2 and infinity.
  • Loading branch information
natgla committed Apr 7, 2016
1 parent c8e6b53 commit 2a4602b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/CGOptions.h
Expand Up @@ -53,7 +53,7 @@ using namespace std;
#define CGOPTIONS_DEFAULT_MAX_STRUCT_FIELDS (10)
#define CGOPTIONS_DEFAULT_MAX_UNION_FIELDS (5)
#define CGOPTIONS_DEFAULT_MAX_NESTED_STRUCT_LEVEL (3)
#define CGOPTIONS_DEFAULT_MAX_INDIRECT_LEVEL (2)
#define CGOPTIONS_DEFAULT_MAX_INDIRECT_LEVEL (5)
#define CGOPTIONS_DEFAULT_MAX_ARRAY_DIMENSIONS (3)
#define CGOPTIONS_DEFAULT_MAX_ARRAY_LENGTH_PER_DIMENSION (10)
#define CGOPTIONS_DEFAULT_MAX_ARRAY_LENGTH (256)
Expand Down
11 changes: 7 additions & 4 deletions src/VariableSelector.cpp
Expand Up @@ -1230,11 +1230,14 @@ VariableSelector::select_deref_pointer(Effect::Access access, const CGContext &c
vars.insert(vars.end(), f->param.begin(), f->param.end());

Variable* var = choose_var(vars, access, cg_context, type, qfer, eDereference, invalid_vars);
ERROR_GUARD(NULL);
if (var == 0) {
Type* ptr_type = Type::find_pointer_type(type, true);
ERROR_GUARD(NULL);
assert(ptr_type);
Type* ptr_type = 0;
if (type->get_indirect_level() < CGOptions::max_indirect_level()) {
ptr_type = Type::find_pointer_type(type, true);
}
if (!ptr_type) {
return 0;
}
CVQualifiers ptr_qfer = (!qfer || qfer->wildcard)
? CVQualifiers::random_qualifiers(ptr_type, access, cg_context, true)
//: qfer->indirect_qualifiers(-1);
Expand Down

0 comments on commit 2a4602b

Please sign in to comment.