Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy initialization of function arguments and variables marked as 'extern' #17

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
25b5a59
refactor: Extract CreateArray method
capsosk May 7, 2022
34ab770
refactor: Extract dumpState method for easier single state debugging
capsosk May 7, 2022
ed682ce
copy concreteAddrressMap when creating new AddressSpace
capsosk May 7, 2022
841c2d0
edit getKValueInfo strings to match reality, unnecessary ternary oper…
capsosk May 7, 2022
cb52b86
Lazily initialize external objects
capsosk May 7, 2022
1ccaa0c
Added max depth for branching of states in cycles
capsosk Mar 25, 2022
97b515c
Use symbolic sizes
capsosk Mar 25, 2022
ec79fb1
Handle writes to lazy-init values
capsosk May 23, 2022
2096599
Lazily initialize function arguments which are pointers
capsosk May 23, 2022
0a13cbe
Implement vararg support
capsosk May 4, 2022
e8f5fc6
Extract method for symbolic size
capsosk Mar 25, 2022
349cc6c
values in function arguments now work as well
capsosk Apr 25, 2022
f2001ec
Tests are formatted and new tests are added
capsosk Mar 13, 2022
f951350
extract method getSymbolicAddressForConstantSegment to avoid repetition
capsosk Apr 23, 2022
b886fc2
correctly handling null check for lazy init variables
capsosk Apr 23, 2022
7f2c88b
comparing equality with address fixed
capsosk Apr 25, 2022
462ff93
Loaded result was missing previously saved offset
capsosk Apr 27, 2022
9909b6b
added test for pointer address equality comparison
capsosk Apr 27, 2022
11ac84b
Fixed a bug when value was not properly read if it is a pointer
capsosk Apr 29, 2022
61e38af
add lazy-init symbolic values to nondet values
capsosk Apr 29, 2022
d1d3f0d
added an option to ignore out of bounds error
capsosk May 3, 2022
f78dfa4
fixes to handleWriteForLazyInit
capsosk May 13, 2022
e71d860
Added new test for changing pointer value
capsosk May 13, 2022
0b1baf9
Global values are now lazy initialized
capsosk May 17, 2022
745d2bf
commented out two warning logs for benchmark purposes
capsosk May 13, 2022
0c8a425
Compare width of the values and unify them if they are constants
capsosk May 16, 2022
58afb56
Support more than 3 arguments in different entry point than main
capsosk May 18, 2022
327c8bd
handleICMPForLazyInit refactored
capsosk May 23, 2022
5bcaa44
refactor symbolic address comparison
capsosk May 30, 2022
78621dd
Fix comparison with function ptr
capsosk Sep 22, 2022
be8009b
Handle symbolic function calls
capsosk Sep 23, 2022
52152e5
Merge pull request #1 from capsosk/function_ptr_cmp
capsosk Oct 22, 2022
07345b2
fix some external calls with symbolic values
capsosk Oct 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/klee/KValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ namespace klee {
: value(value), pointerSegment(ConstantExpr::alloc(VALUES_SEGMENT, value->getWidth())) {}
KValue(ref<Expr> segment, ref<Expr> offset)
: value(offset), pointerSegment(segment) {}
KValue(uint64_t segment, ref<Expr> offset)
: value(offset), pointerSegment(ConstantExpr::alloc(segment, value->getWidth())) {}

KValue(SpecialSegment segment, ref<Expr> offset)
: value(offset), pointerSegment(ConstantExpr::alloc(segment, value->getWidth())) {}
Expand Down
14 changes: 12 additions & 2 deletions lib/Core/AddressSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,23 @@ void AddressSpace::bindObject(const MemoryObject *mo, ObjectState *os) {
assert(os->copyOnWriteOwner==0 && "object already has owner");
os->copyOnWriteOwner = cowKey;
objects = objects.replace(std::make_pair(mo, os));
if (mo->segment != 0)
if (mo->segment != 0) {
segmentMap = segmentMap.replace(std::make_pair(mo->segment, mo));
if (mo->isLazyInitialized) {
lazilyInitializedOffsets.insert({mo->getSegment(), {}});
}
}

}

void AddressSpace::unbindObject(const MemoryObject *mo) {
if (mo->segment != 0)
if (mo->segment != 0) {
segmentMap = segmentMap.remove(mo->segment);
if (mo->isLazyInitialized) {
lazilyInitializedOffsets.erase(mo->segment);
}
}

objects = objects.remove(mo);
// NOTE MemoryObjects are reference counted, *mo is deleted at this point
}
Expand Down
12 changes: 11 additions & 1 deletion lib/Core/AddressSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ typedef ImmutableMap<uint64_t, const MemoryObject*> SegmentMap;
typedef std::map</*address*/ const uint64_t, /*segment*/ const uint64_t> ConcreteAddressMap;
typedef std::map</*segment*/ const uint64_t, /*address*/ const uint64_t> SegmentAddressMap;
typedef std::map</*segment*/ const uint64_t, /*symbolic array*/ ref<Expr>> RemovedObjectsMap;
typedef std::map</*pointer segment*/ const uint64_t, /*value segment:offset*/ std::pair<uint64_t, uint64_t>> LazyPointersSegmentMap;
typedef std::map</*segment*/ const uint64_t, /*lazily initialized offsets*/std::vector<uint64_t>> LazilyInitializedOffsets;


class AddressSpace {
friend class ExecutionState;
Expand Down Expand Up @@ -67,12 +70,19 @@ class AddressSpace {

RemovedObjectsMap removedObjectsMap;

LazilyInitializedOffsets lazilyInitializedOffsets;

LazyPointersSegmentMap lazyPointersSegmentMap;

AddressSpace() : cowKey(1) {}
AddressSpace(const AddressSpace &b)
: cowKey(++b.cowKey),
objects(b.objects),
segmentMap(b.segmentMap),
removedObjectsMap(b.removedObjectsMap) { }
concreteAddressMap(b.concreteAddressMap),
removedObjectsMap(b.removedObjectsMap),
lazilyInitializedOffsets(b.lazilyInitializedOffsets),
lazyPointersSegmentMap(b.lazyPointersSegmentMap){ }
~AddressSpace() {}

/// Looks up constant segment in concreteAddressMap.
Expand Down
Loading