diff --git a/Makefile b/Makefile index 0b9455b318..5bef90f416 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,7 @@ DIRECT_TESTS += \ c_performance \ c_pulse \ c_pulse-over-only \ + c_pulse-over-only-balanced \ c_pulse-over-under \ c_purity \ c_export-textual \ diff --git a/infer/src/absint/AbstractInterpreter.ml b/infer/src/absint/AbstractInterpreter.ml index 45aae29d87..8d6108c937 100644 --- a/infer/src/absint/AbstractInterpreter.ml +++ b/infer/src/absint/AbstractInterpreter.ml @@ -443,7 +443,8 @@ struct (((post, non_disj_astates) as post_astate), dropped, n_disjuncts, extra) pre_disjunct -> - if n_disjuncts >= global_limit && not (use_balanced_disjunct_strategy ()) then ( + (* the balanced strategy below gives a disjunct a [limit] of 0 exactly when this holds *) + if n_disjuncts >= global_limit then ( L.d_printfln "@[Reached max disjuncts limit, skipping disjunct #%d@;@]" i ; (post_astate, pre_disjunct :: dropped, n_disjuncts, 0) ) else diff --git a/infer/tests/build_systems/disjunctive_domain/disjunctive.exp b/infer/tests/build_systems/disjunctive_domain/disjunctive.exp index 043c331894..15492f7ca4 100644 --- a/infer/tests/build_systems/disjunctive_domain/disjunctive.exp +++ b/infer/tests/build_systems/disjunctive_domain/disjunctive.exp @@ -223,7 +223,7 @@ loop: #2: two_branch0.0.two_branch1.0 #3: two_branch0.0.two_branch1.1 Non-disjunctive state: ⊥ -CFG Metadata: dropped_disjuncts= 5; interrupted_loops= 0 +CFG Metadata: dropped_disjuncts= 7; interrupted_loops= 0 No issues found @@ -283,7 +283,7 @@ loop: #8: two_branch0.0.two_branch1.1.two_branch4.0 #9: two_branch0.0.two_branch1.1.two_branch4.1 Non-disjunctive state: ⊥ -CFG Metadata: dropped_disjuncts= 6; interrupted_loops= 1 +CFG Metadata: dropped_disjuncts= 10; interrupted_loops= 1 No issues found diff --git a/infer/tests/codetoanalyze/c/pulse-over-only-balanced/Makefile b/infer/tests/codetoanalyze/c/pulse-over-only-balanced/Makefile new file mode 100644 index 0000000000..1bcb72b378 --- /dev/null +++ b/infer/tests/codetoanalyze/c/pulse-over-only-balanced/Makefile @@ -0,0 +1,23 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +TESTS_DIR = ../../.. + +# The tests of ../pulse-over-only with the balanced disjunct strategy, which must give the same +# results since no disjunct is kept + +CLANG_OPTIONS = -c +INFER_OPTIONS = \ + --pulse-only --debug-exceptions --project-root $(TESTS_DIR) \ + --pulse-report-issues-for-tests --no-pulse-force-continue \ + --pulse-max-disjuncts 0 --pulse-over-approximate-reasoning \ + --pulse-balanced-disjuncts-strategy \ + --pulse-transitive-access-config ../pulse-over-only/transitive-access.conf \ + +INFERPRINT_OPTIONS = --issues-tests + +SOURCES = $(wildcard ../pulse-over-only/*.c) + +include $(TESTS_DIR)/clang.make diff --git a/infer/tests/codetoanalyze/c/pulse-over-only-balanced/issues.exp b/infer/tests/codetoanalyze/c/pulse-over-only-balanced/issues.exp new file mode 100644 index 0000000000..ff67b3b6a6 --- /dev/null +++ b/infer/tests/codetoanalyze/c/pulse-over-only-balanced/issues.exp @@ -0,0 +1,10 @@ +codetoanalyze/c/pulse-over-only/attributes.c, init_one_branch_only_bad, 5, PULSE_UNINITIALIZED_VALUE, no_bucket, ERROR, [variable `x` declared here,read to uninitialized value occurs here] +codetoanalyze/c/pulse-over-only/attributes.c, FNsuppressed_invalid_one_branch_only_bad, 6, NULLPTR_DEREFERENCE, no_bucket, ERROR, [*** SUPPRESSED ***,source of the null value part of the trace starts here,assigned,is assigned to the null pointer,null pointer dereference part of the trace starts here,invalid access occurs here] +codetoanalyze/c/pulse-over-only/attributes.c, interproc_joined_invalid_deref_bad, 2, NULLPTR_DEREFERENCE, no_bucket, ERROR, [*** SUPPRESSED ***,source of the null value part of the trace starts here,when calling `get_maybe_invalid_pointer` here,assigned,is assigned to the null pointer,null pointer dereference part of the trace starts here,in call to `get_maybe_invalid_pointer`,assigned,when calling `maybe_deref_pointer` here,parameter `p` of maybe_deref_pointer,invalid access occurs here] +codetoanalyze/c/pulse-over-only/attributes.c, FP_interproc_path_sensitive_valid_deref_ok, 2, NULLPTR_DEREFERENCE, no_bucket, ERROR, [*** SUPPRESSED ***,source of the null value part of the trace starts here,when calling `get_maybe_invalid_pointer` here,assigned,is assigned to the null pointer,null pointer dereference part of the trace starts here,in call to `get_maybe_invalid_pointer`,assigned,when calling `maybe_deref_pointer` here,parameter `p` of maybe_deref_pointer,invalid access occurs here] +codetoanalyze/c/pulse-over-only/formula.c, FP_same_facts_different_branches_ok, 19, NULLPTR_DEREFERENCE, no_bucket, ERROR, [is assigned to the null pointer,assigned,invalid access occurs here] +codetoanalyze/c/pulse-over-only/formula.c, FP_same_facts_different_branches_ok, 23, NULLPTR_DEREFERENCE, no_bucket, ERROR, [is assigned to the null pointer,assigned,invalid access occurs here] +codetoanalyze/c/pulse-over-only/join.c, join_valid_invalid_pointers, 1, NULLPTR_DEREFERENCE_LATENT, no_bucket, ERROR, [*** SUPPRESSED ***,source of the null value part of the trace starts here,is assigned to the null pointer,null pointer dereference part of the trace starts here,parameter `p` of join_valid_invalid_pointers,invalid access occurs here] +codetoanalyze/c/pulse-over-only/join.c, continue_after_fatal_bad2, 8, NULLPTR_DEREFERENCE, no_bucket, ERROR, [*** SUPPRESSED ***,source of the null value part of the trace starts here,assigned,is assigned to the null pointer,null pointer dereference part of the trace starts here,invalid access occurs here] +codetoanalyze/c/pulse-over-only/join.c, continue_after_fatal_bad2, 10, NULLPTR_DEREFERENCE, no_bucket, ERROR, [is assigned to the null pointer,assigned,invalid access occurs here] +codetoanalyze/c/pulse-over-only/transitive-access.c, source_bad, 0, PULSE_TRANSITIVE_ACCESS, no_bucket, ERROR, [when calling `wrapper_ok` here,access occurs here]