-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* BST test * Added fixed BST test * added test case for uninit ptr * Partial implementation of fix for null deref aborting the whole program instead of a single path * Instead of aborting on null pointder deref, abort only the current path and create a test * some pointer testcases * updated uninitV on cpp end, made pointer arithmetic state-aware, attempted to throw exception for symvite pointers since they are uninit and possibly null * reorg test case * ptr_add has to know complete type SS * fix test cases * test both stp and z3 * try simplify backend ptr_add * move ptr_add back to value_ops.hpp * Added expected nPath for faultyBst, added additional cases to SS::update() to handle invalid pointers * added uninit ptr update and some code * finished update for uninit pointers by adding update_symloc * merged with Ruiqi's changes * argv separate test * fixed condition in get_sym_string_at * append null byte to arguments instead of uninitv * reverted unintentional value_ops changs, updated FaultyBST expected paths * reverted condition to fix argvConc, which has been fixed by a different change * Fixed flexAddr, added comments about assume * fix for assume.c, made calloc actually zero * made __calloc zero memory for PureGS * made stack arrays a different symbolic value for each index, fixed some other tests * added copynative2state constraints in PureGS to fix printf.c * Fixed bad test :/ * work on putting symbolic uninit behind a flag * fixed test with flags * made compile symbolicUninit imply runtime symbolicUninit * made tests set symbolicUninit correctly with a hack * refactor config * set symbolicUninit to false after test case * updated a test case for symbolicUninit * fixed final symbolicUninit test :/ * cleaned up symbolicUninit testcases * fixed duplicate test names * removed external_test.cpp --------- Co-authored-by: Mikail Khan <mikail@mikail-khan.com>
- Loading branch information
Showing
30 changed files
with
413 additions
and
119 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#include <stdio.h> | ||
#include <assert.h> | ||
#include <stdbool.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#ifdef KLEE | ||
#include "klee/klee.h" | ||
#endif | ||
|
||
#define SIZE 4 | ||
|
||
typedef struct node_s { | ||
struct node_s* left; | ||
struct node_s* right; | ||
int val; | ||
} Node; | ||
|
||
Node* init_node(int val) { | ||
Node* new_node = malloc(sizeof(Node)); | ||
new_node->val = val; | ||
|
||
// Because these are left uninitialized, | ||
// there may be an error in insert and find | ||
/* new_node->left = NULL; */ | ||
/* new_node->right = NULL; */ | ||
|
||
return new_node; | ||
} | ||
|
||
Node* bst_insert(Node* root, int val) { | ||
if (root == NULL) { | ||
return init_node(val); | ||
} | ||
|
||
assert(root != NULL); | ||
if (root->val == -1) { | ||
return init_node(val); | ||
} | ||
|
||
if (val > root->val) { | ||
root->right = bst_insert(root->right, val); | ||
return root; | ||
} else { | ||
root->left = bst_insert(root->left, val); | ||
return root; | ||
} | ||
} | ||
|
||
Node* bst_from_list(int* arr, int len) { | ||
Node* root = NULL; | ||
for (int i = 0; i < len; i += 1) { | ||
root = bst_insert(root, arr[i]); | ||
} | ||
|
||
return root; | ||
} | ||
|
||
/* void bst_print_aux(Node* root) { */ | ||
/* if (root != NULL) { */ | ||
/* printf("%d ", root->val); */ | ||
/* bst_print_aux(root->left); */ | ||
/* bst_print_aux(root->right); */ | ||
/* } */ | ||
/* } */ | ||
|
||
/* void bst_print(Node* root) { */ | ||
/* bst_print_aux(root); */ | ||
/* printf("\n"); */ | ||
/* } */ | ||
|
||
bool bst_find(Node* root, int key) { | ||
if (root == NULL || root->val == -1) { | ||
return false; | ||
} else if (key == root->val) { | ||
return true; | ||
} else if (key > root->val) { | ||
return bst_find(root->right, key); | ||
} else { | ||
return bst_find(root->left, key); | ||
} | ||
} | ||
|
||
int main() { | ||
int data[SIZE]; | ||
int key; | ||
/* for (int i = 0; i < SIZE; i += 1) { */ | ||
/* data[i] = i; */ | ||
/* } */ | ||
#ifdef KLEE | ||
klee_make_symbolic(data, sizeof(data), "data"); | ||
klee_make_symbolic(&key, sizeof(int), "key"); | ||
#else | ||
make_symbolic(data, sizeof(int) * SIZE, "data"); | ||
make_symbolic(&key, sizeof(int), "key"); | ||
#endif | ||
|
||
Node* tree = bst_from_list(data, SIZE); | ||
/* bst_print(tree); */ | ||
bst_find(tree, key); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdlib.h> | ||
|
||
#ifdef KLEE | ||
#include "klee/klee.h" | ||
#endif | ||
|
||
int main() { | ||
int* ptr; | ||
|
||
#ifdef KLEE | ||
klee_make_symbolic(&ptr, sizeof(int*), "ptr"); | ||
#else | ||
make_symbolic(&ptr, sizeof(int*), "ptr"); | ||
#endif | ||
|
||
if (ptr == NULL) { | ||
return 0; | ||
} else { | ||
return *ptr; | ||
} | ||
} |
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 @@ | ||
#include <stdlib.h> | ||
|
||
// This test must be run with --thread=1 | ||
// so that the NullDerefException is caught | ||
|
||
int main() { | ||
int* ptr; | ||
return *ptr; | ||
} |
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,14 @@ | ||
#include <stdlib.h> | ||
|
||
// This test must be run with --thread=1 | ||
// so that the NullDerefException is caught | ||
|
||
int main() { | ||
int* ptr; | ||
|
||
if (ptr == NULL) { | ||
return 0; | ||
} else { | ||
return *ptr; | ||
} | ||
} |
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,10 @@ | ||
#include <stdlib.h> | ||
|
||
// This test must be run with --thread=1 | ||
// so that the NullDerefException is caught | ||
|
||
int main() { | ||
int* ptr; | ||
*ptr = 10; | ||
return *ptr; | ||
} |
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
Oops, something went wrong.