-
Notifications
You must be signed in to change notification settings - Fork 273
CONTRACTS: Dynamic frame condition checking #7242
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
Merged
remi-delmas-3000
merged 1 commit into
diffblue:develop
from
remi-delmas-3000:rebase-dfcc-fix-regression
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,43 @@ | ||
if(WIN32) | ||
set(is_windows true) | ||
else() | ||
set(is_windows false) | ||
endif() | ||
|
||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
set(gcc_only -X gcc-only) | ||
set(gcc_only_string "-X;gcc-only;") | ||
else() | ||
set(gcc_only "") | ||
set(gcc_only_string "") | ||
endif() | ||
|
||
|
||
add_test_pl_tests( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:goto-instrument> $<TARGET_FILE:cbmc> ${is_windows}" | ||
) | ||
|
||
## Enabling these causes a very significant increase in the time taken to run the regressions | ||
|
||
#add_test_pl_profile( | ||
# "cbmc-z3" | ||
# "${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:goto-instrument> '$<TARGET_FILE:cbmc> --z3' ${is_windows}" | ||
# "-C;-X;broken-smt-backend;-X;thorough-smt-backend;-X;broken-z3-backend;-X;thorough-z3-backend;${gcc_only_string}-s;z3" | ||
# "CORE" | ||
#) | ||
|
||
#add_test_pl_profile( | ||
# "cbmc-cprover-smt2" | ||
# "${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:goto-instrument> '$<TARGET_FILE:cbmc> --cprover-smt2' ${is_windows}" | ||
# "-C;-X;broken-smt-backend;-X;thorough-smt-backend;-X;broken-cprover-smt2-backend;-X;thorough-cprover-smt2-backend;${gcc_only_string}-s;cprover-smt2" | ||
# "CORE" | ||
#) | ||
|
||
# solver appears on the PATH in Windows already | ||
#if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") | ||
# set_property( | ||
# TEST "cbmc-cprover-smt2-CORE" | ||
# PROPERTY ENVIRONMENT | ||
# "PATH=$ENV{PATH}:$<TARGET_FILE_DIR:smt2_solver>" | ||
# ) | ||
#endif() |
This file contains hidden or 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,42 @@ | ||
default: test | ||
|
||
include ../../src/config.inc | ||
include ../../src/common | ||
|
||
ifeq ($(BUILD_ENV_),MSVC) | ||
exe=../../../src/goto-cc/goto-cl | ||
is_windows=true | ||
GCC_ONLY = -X gcc-only | ||
else | ||
exe=../../../src/goto-cc/goto-cc | ||
is_windows=false | ||
GCC_ONLY = | ||
endif | ||
|
||
test: | ||
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-instrument/goto-instrument ../../../src/cbmc/cbmc $(is_windows)' -X smt-backend $(GCC_ONLY) | ||
|
||
test-cprover-smt2: | ||
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-instrument/goto-instrument "../../../src/cbmc/cbmc --cprover-smt2" $(is_windows)' \ | ||
-X broken-smt-backend -X thorough-smt-backend \ | ||
-X broken-cprover-smt-backend -X thorough-cprover-smt-backend \ | ||
-s cprover-smt2 $(GCC_ONLY) | ||
|
||
test-z3: | ||
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-instrument/goto-instrument "../../../src/cbmc/cbmc --z3" $(is_windows)' \ | ||
-X broken-smt-backend -X thorough-smt-backend \ | ||
-X broken-z3-smt-backend -X thorough-z3-smt-backend \ | ||
-s z3 $(GCC_ONLY) | ||
|
||
tests.log: ../test.pl test | ||
|
||
|
||
clean: | ||
@for dir in *; do \ | ||
$(RM) tests.log; \ | ||
if [ -d "$$dir" ]; then \ | ||
cd "$$dir"; \ | ||
$(RM) *.out *.gb *.smt2; \ | ||
cd ..; \ | ||
fi \ | ||
done |
31 changes: 31 additions & 0 deletions
31
regression/contracts-dfcc/assigns-enforce-malloc-zero/main.c
This file contains hidden or 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,31 @@ | ||
#include <stdlib.h> | ||
|
||
// returns the index at which the write was performed if any | ||
// -1 otherwise | ||
int foo(char *a, int size) | ||
// clang-format off | ||
__CPROVER_requires(0 <= size && size <= __CPROVER_max_malloc_size) | ||
__CPROVER_requires(a == NULL || __CPROVER_is_fresh(a, size)) | ||
__CPROVER_assigns(a: __CPROVER_object_whole(a)) | ||
__CPROVER_ensures( | ||
a && __CPROVER_return_value >= 0 ==> a[__CPROVER_return_value] == 0) | ||
// clang-format on | ||
{ | ||
if(!a) | ||
return -1; | ||
int i; | ||
if(0 <= i && i < size) | ||
{ | ||
a[i] = 0; | ||
return i; | ||
} | ||
return -1; | ||
} | ||
|
||
int main() | ||
{ | ||
size_t size; | ||
char *a; | ||
foo(a, size); | ||
return 0; | ||
} |
11 changes: 11 additions & 0 deletions
11
regression/contracts-dfcc/assigns-enforce-malloc-zero/test.desc
This file contains hidden or 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 @@ | ||
CORE | ||
main.c | ||
--dfcc main --enforce-contract foo _ --malloc-may-fail --malloc-fail-null | ||
^\[foo.assigns.\d+\] line 19 Check that a\[\(signed long (long )?int\)i\] is assignable: SUCCESS$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
This test checks that objects of size zero or __CPROVER_max_malloc_size | ||
do not cause spurious falsifications in assigns clause instrumentation | ||
in contract enforcement mode. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need
--enforce-contract-rec
in this PR? If so, why? I might have expected these to be two separate PRs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doable but pulling out support for recursive functions from this PR would take me quite some time again