Skip to content

Commit b66babc

Browse files
Only unwind loops without contracts in DFCC mode (#195)
* Only unwind loops without contracts in DFCC mode * We must not use default unwind with DFCC mode * Update src/cbmc_starter_kit/template-for-repository/proofs/Makefile.common * Update src/cbmc_starter_kit/template-for-repository/proofs/Makefile.common --------- Signed-off-by: Felipe R. Monteiro <[email protected]> Co-authored-by: Rémi Delmas <[email protected]>
1 parent dac7b1c commit b66babc

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/cbmc_starter_kit/template-for-repository/proofs/Makefile.common

+22-4
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,24 @@ ifdef APPLY_LOOP_CONTRACTS
450450
endif
451451
endif
452452

453+
# The default unwind should only be used in DFCC mode without loop contracts.
454+
# When loop contracts are applied, we only unwind specified loops.
455+
# If any loops remain after loop contracts have been applied, CBMC might try
456+
# to unwind the program indefinetly, because we do not pass default unwind
457+
# (i.e., --unwind 1) to CBMC when in DFCC mode.
458+
# We must not use a default unwind command in DFCC mode, because contract instrumentation
459+
# introduces loops encoding write set inclusion checks that must be dynamically unwound during
460+
# symex.
461+
ifneq ($(strip $(USE_DYNAMIC_FRAMES)),)
462+
ifneq ($(strip $(APPLY_LOOP_CONTRACTS)),)
463+
UNWIND_0500_FLAGS=$(CBMC_UNWINDSET) $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_FLAG_UNWINDING_ASSERTIONS)
464+
UNWIND_0500_DESC="$(PROOF_UID): unwinding specified subset of loops"
465+
else
466+
UNWIND_0500_FLAGS=$(CBMC_UNWINDSET) $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_DEFAULT_UNWIND) $(CBMC_FLAG_UNWINDING_ASSERTIONS)
467+
UNWIND_0500_DESC="$(PROOF_UID): unwinding all loops"
468+
endif
469+
endif
470+
453471
# Silence makefile output (eg, long litani commands) unless VERBOSE is set.
454472
ifndef VERBOSE
455473
MAKEFLAGS := $(MAKEFLAGS) -s
@@ -713,13 +731,13 @@ $(HARNESS_GOTO)0500.goto: $(HARNESS_GOTO)0400.goto
713731
ifneq ($(strip $(USE_DYNAMIC_FRAMES)),)
714732
$(LITANI) add-job \
715733
--command \
716-
'$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) $(CBMC_UNWINDSET) $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_DEFAULT_UNWIND) $(CBMC_FLAG_UNWINDING_ASSERTIONS) $^ $@' \
734+
'$(GOTO_INSTRUMENT) $(CBMC_VERBOSITY) $(UNWIND_0500_FLAGS) $^ $@' \
717735
--inputs $^ \
718736
--outputs $@ \
719737
--stdout-file $(LOGDIR)/unwind_loops-log.txt \
720738
--pipeline-name "$(PROOF_UID)" \
721739
--ci-stage build \
722-
--description "$(PROOF_UID): unwinding all loops"
740+
--description $(UNWIND_0500_DESC)
723741
else ifneq ($(strip $(CODE_CONTRACTS)),)
724742
$(LITANI) add-job \
725743
--command \
@@ -735,7 +753,7 @@ else
735753
--command 'cp $^ $@' \
736754
--inputs $^ \
737755
--outputs $@ \
738-
--stdout-file $(LOGDIR)/linking-library-models-log.txt \
756+
--stdout-file $(LOGDIR)/unwind_loops-log.txt \
739757
--pipeline-name "$(PROOF_UID)" \
740758
--ci-stage build \
741759
--description "$(PROOF_UID): not unwinding loops"
@@ -794,7 +812,7 @@ ifdef CBMCFLAGS
794812
ifeq ($(strip $(CODE_CONTRACTS)),)
795813
CBMCFLAGS += $(CBMC_UNWINDSET) $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_DEFAULT_UNWIND) $(CBMC_OPT_CONFIG_LIBRARY)
796814
else ifeq ($(strip $(USE_DYNAMIC_FRAMES)),)
797-
CBMCFLAGS += $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_DEFAULT_UNWIND) $(CBMC_OPT_CONFIG_LIBRARY)
815+
CBMCFLAGS += $(CBMC_CPROVER_LIBRARY_UNWINDSET) $(CBMC_OPT_CONFIG_LIBRARY)
798816
endif
799817
endif
800818

0 commit comments

Comments
 (0)