-
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.
Add nondet assignment to non-zero'd allocations in symex
This change means that if a generation zero symex variable is seen it can be assumed to not have been allocated at any point and still have its default values. We use this knowledge to then not add a guard on a phi merge that has a gen zero on its lhs or rhs, instead just simply assigning the other side directly.
- Loading branch information
1 parent
41d7a45
commit 3b306f4
Showing
12 changed files
with
163 additions
and
2 deletions.
There are no files selected for viewing
Binary file added
BIN
+1.48 KB
regression/cbmc-java/phi-merge_uninitialized_values/PhiMergeUninitialized.class
Binary file not shown.
56 changes: 56 additions & 0 deletions
56
regression/cbmc-java/phi-merge_uninitialized_values/PhiMergeUninitialized.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,56 @@ | ||
public class PhiMergeUninitialized { | ||
|
||
public int dynamicAllocationUninitialized(Boolean trigger) { | ||
|
||
Ephemeral obj; | ||
if (trigger) { | ||
obj = new Ephemeral(42); | ||
} else { | ||
obj = new Aetherial(20); | ||
} | ||
|
||
assert obj.val == 20; | ||
return obj.val; | ||
} | ||
|
||
private Ephemeral local; | ||
|
||
public int localUninitialized(Boolean trigger) { | ||
if (trigger) { | ||
local = new Ephemeral(42); | ||
} else { | ||
local = new Aetherial(50); | ||
} | ||
|
||
assert local.val == 42; | ||
return local.val; | ||
} | ||
|
||
private static Ephemeral staticLocal; | ||
|
||
public int staticLocalUninitialized(Boolean trigger) { | ||
if (trigger) { | ||
staticLocal = new Ephemeral(42); | ||
} else { | ||
staticLocal = new Aetherial(76); | ||
} | ||
|
||
assert staticLocal.val == 76; | ||
return staticLocal.val; | ||
} | ||
|
||
class Ephemeral { | ||
Ephemeral(int value) { | ||
val = value; | ||
} | ||
|
||
int val; | ||
} | ||
|
||
class Aetherial extends Ephemeral { | ||
Aetherial(int value) { | ||
super(value); | ||
} | ||
} | ||
} | ||
|
9 changes: 9 additions & 0 deletions
9
regression/cbmc-java/phi-merge_uninitialized_values/local.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,9 @@ | ||
CORE | ||
PhiMergeUninitialized.class | ||
--function PhiMergeUninitialized.dynamicAllocationUninitialized --show-vcc | ||
activate-multi-line-match | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^.*: (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0\) | ||
^.*\? (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0 |
9 changes: 9 additions & 0 deletions
9
regression/cbmc-java/phi-merge_uninitialized_values/member.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,9 @@ | ||
CORE | ||
PhiMergeUninitialized.class | ||
--function PhiMergeUninitialized.localUninitialized --show-vcc | ||
activate-multi-line-match | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^.*: (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0\) | ||
^.*\? (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0 |
9 changes: 9 additions & 0 deletions
9
regression/cbmc-java/phi-merge_uninitialized_values/static.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,9 @@ | ||
CORE | ||
PhiMergeUninitialized.class | ||
--function PhiMergeUninitialized.staticLocalUninitialized --show-vcc | ||
activate-multi-line-match | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^.*: (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0\) | ||
^.*\? (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0 |
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 @@ | ||
CORE | ||
test.c | ||
--function dynamicAllocationUninitialized --show-vcc | ||
activate-multi-line-match | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^.*: (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0\) | ||
^.*\? (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0 |
9 changes: 9 additions & 0 deletions
9
regression/cbmc/phi-merge_uninitialized_values/static_global.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,9 @@ | ||
CORE | ||
test.c | ||
--function staticLocalUninitialized --show-vcc | ||
activate-multi-line-match | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^.*: (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0\) | ||
^.*\? (dynamic_object|new_tmp[0-9]+(@[0-9]+)?)[0-9]+#0 |
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,34 @@ | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
void dynamicAllocationUninitialized(int trigger) | ||
{ | ||
int *obj; | ||
obj = malloc(sizeof(int)); | ||
if(trigger) | ||
{ | ||
*obj = 42; | ||
} | ||
else | ||
{ | ||
*obj = 20; | ||
} | ||
|
||
assert(*obj == 20); | ||
} | ||
|
||
int *staticLocal; | ||
int staticLocalUninitialized(int trigger) | ||
{ | ||
staticLocal = malloc(sizeof(int)); | ||
if(trigger) | ||
{ | ||
*staticLocal = 42; | ||
} | ||
else | ||
{ | ||
*staticLocal = 76; | ||
} | ||
|
||
assert(*staticLocal == 76); | ||
} |
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