diff --git a/Makefile b/Makefile index 14466f2aa1..e4d5c26d49 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,7 @@ DIRECT_TESTS += \ objc_pulse \ objc_pulse-data-lineage \ objc_self-in-block \ - objc_dispatch-once-static-init \ + objc_static-constructor-stall \ objcpp_biabduction \ objcpp_frontend \ objcpp_liveness \ diff --git a/infer/man/man1/infer-analyze.txt b/infer/man/man1/infer-analyze.txt index ca4397a0ed..4c3fa56b9b 100644 --- a/infer/man/man1/infer-analyze.txt +++ b/infer/man/man1/infer-analyze.txt @@ -114,7 +114,7 @@ OPTIONS and/or reporting. (Conversely: --deduplicate) --no-default-checkers - Deactivates: Default checkers: --dispatch-once-static-init, + Deactivates: Default checkers: --static-constructor-stall-checker, --fragment-retains-view, --inefficient-keyset-iterator, --liveness, --parameter-not-null-checked, --pulse, --racerd, --siof, --self-in-block, --starvation (Conversely: @@ -131,15 +131,6 @@ OPTIONS --dict-missing-key-var-block-list +string Skip analyzing the variables in the dict-missing-key checker. - --no-dispatch-once-static-init - Deactivates: dispatch-once-static-init checker: Detect if - dispatch_once is called from a static constructor. (Conversely: - --dispatch-once-static-init) - - --dispatch-once-static-init-only - Activates: Enable dispatch-once-static-init and disable all other - checkers (Conversely: --no-dispatch-once-static-init-only) - --files-to-analyze-index file File containing a list of source files where analysis should start from. When used, the set of files given to this argument must be a @@ -445,6 +436,16 @@ OPTIONS Activates: Enable starvation and disable all other checkers (Conversely: --no-starvation-only) + --no-static-constructor-stall-checker + Deactivates: static-constructor-stall-checker checker: Detect if + dispatch_once is called from a static constructor. (Conversely: + --static-constructor-stall-checker) + + --static-constructor-stall-checker-only + Activates: Enable static-constructor-stall-checker and disable all + other checkers (Conversely: + --no-static-constructor-stall-checker-only) + --timeout float Time after which any checker (except biabduction) should give up analysing the current function or method, in seconds diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index e36f03deae..fd0dd70ac6 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -539,7 +539,7 @@ OPTIONS infer-reportdiff(1). --no-default-checkers - Deactivates: Default checkers: --dispatch-once-static-init, + Deactivates: Default checkers: --static-constructor-stall-checker, --fragment-retains-view, --inefficient-keyset-iterator, --liveness, --parameter-not-null-checked, --pulse, --racerd, --siof, --self-in-block, --starvation (Conversely: @@ -769,17 +769,6 @@ OPTIONS See also infer-report(1). - --no-dispatch-once-static-init - Deactivates: dispatch-once-static-init checker: Detect if - dispatch_once is called from a static constructor. (Conversely: - --dispatch-once-static-init) - See also infer-analyze(1). - - --dispatch-once-static-init-only - Activates: Enable dispatch-once-static-init and disable all other - checkers (Conversely: --no-dispatch-once-static-init-only) - See also infer-analyze(1). - --dump-duplicate-symbols Activates: Dump all symbols with the same name that are defined in more than one file. (Conversely: --no-dump-duplicate-symbols) @@ -2250,6 +2239,18 @@ OPTIONS (Conversely: --no-starvation-only) See also infer-analyze(1). + --no-static-constructor-stall-checker + Deactivates: static-constructor-stall-checker checker: Detect if + dispatch_once is called from a static constructor. (Conversely: + --static-constructor-stall-checker) + See also infer-analyze(1). + + --static-constructor-stall-checker-only + Activates: Enable static-constructor-stall-checker and disable all + other checkers (Conversely: + --no-static-constructor-stall-checker-only) + See also infer-analyze(1). + --stats-dir-current path The infer-out/stats from the current run. Together with --stats-dir-previous, make infer reportdiff compute the difference diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 25a472cfc8..20ac7b05b1 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -539,7 +539,7 @@ OPTIONS infer-reportdiff(1). --no-default-checkers - Deactivates: Default checkers: --dispatch-once-static-init, + Deactivates: Default checkers: --static-constructor-stall-checker, --fragment-retains-view, --inefficient-keyset-iterator, --liveness, --parameter-not-null-checked, --pulse, --racerd, --siof, --self-in-block, --starvation (Conversely: @@ -769,17 +769,6 @@ OPTIONS See also infer-report(1). - --no-dispatch-once-static-init - Deactivates: dispatch-once-static-init checker: Detect if - dispatch_once is called from a static constructor. (Conversely: - --dispatch-once-static-init) - See also infer-analyze(1). - - --dispatch-once-static-init-only - Activates: Enable dispatch-once-static-init and disable all other - checkers (Conversely: --no-dispatch-once-static-init-only) - See also infer-analyze(1). - --dump-duplicate-symbols Activates: Dump all symbols with the same name that are defined in more than one file. (Conversely: --no-dump-duplicate-symbols) @@ -2250,6 +2239,18 @@ OPTIONS (Conversely: --no-starvation-only) See also infer-analyze(1). + --no-static-constructor-stall-checker + Deactivates: static-constructor-stall-checker checker: Detect if + dispatch_once is called from a static constructor. (Conversely: + --static-constructor-stall-checker) + See also infer-analyze(1). + + --static-constructor-stall-checker-only + Activates: Enable static-constructor-stall-checker and disable all + other checkers (Conversely: + --no-static-constructor-stall-checker-only) + See also infer-analyze(1). + --stats-dir-current path The infer-out/stats from the current run. Together with --stats-dir-previous, make infer reportdiff compute the difference diff --git a/infer/src/backend/Payloads.ml b/infer/src/backend/Payloads.ml index 8464126898..4d787040b3 100644 --- a/infer/src/backend/Payloads.ml +++ b/infer/src/backend/Payloads.ml @@ -17,7 +17,7 @@ type t = ; config_impact_analysis: ConfigImpactAnalysis.Summary.t Lazy.t option ; cost: CostDomain.summary Lazy.t option ; disjunctive_demo: DisjunctiveDemo.domain Lazy.t option - ; dispatch_once_static_init: DispatchOnceStaticInit.Summary.t Lazy.t option + ; static_constructor_stall_checker: StaticConstructorStallChecker.Summary.t Lazy.t option ; lab_resource_leaks: ResourceLeakDomain.summary Lazy.t option ; litho_required_props: LithoDomain.summary Lazy.t option ; pulse: PulseSummary.t Lazy.t option @@ -65,8 +65,8 @@ let all_fields = ~config_impact_analysis:(fun f -> mk f ConfigImpactAnalysis ConfigImpactAnalysis.Summary.pp) ~cost:(fun f -> mk f Cost CostDomain.pp_summary) ~disjunctive_demo:(fun f -> mk f DisjunctiveDemo DisjunctiveDemo.pp_domain) - ~dispatch_once_static_init:(fun f -> - mk f DispatchOnceStaticInit DispatchOnceStaticInit.Summary.pp ) + ~static_constructor_stall_checker:(fun f -> + mk f StaticConstructorStallChecker StaticConstructorStallChecker.Summary.pp ) ~litho_required_props:(fun f -> mk f LithoRequiredProps LithoDomain.pp_summary) ~pulse:(fun f -> mk_full f Pulse PulseSummary.pp) ~purity:(fun f -> mk f Purity PurityDomain.pp_summary) @@ -111,7 +111,7 @@ let empty = ; config_impact_analysis= None ; cost= None ; disjunctive_demo= None - ; dispatch_once_static_init= None + ; static_constructor_stall_checker= None ; lab_resource_leaks= None ; litho_required_props= None ; pulse= None @@ -210,7 +210,8 @@ module SQLite = struct Fields.make_creator ~annot_map:data_of_sqlite_column ~biabduction:data_of_sqlite_column ~buffer_overrun_analysis:data_of_sqlite_column ~buffer_overrun_checker:data_of_sqlite_column ~config_impact_analysis:data_of_sqlite_column ~cost:data_of_sqlite_column - ~disjunctive_demo:data_of_sqlite_column ~dispatch_once_static_init:data_of_sqlite_column + ~disjunctive_demo:data_of_sqlite_column + ~static_constructor_stall_checker:data_of_sqlite_column ~litho_required_props:data_of_sqlite_column ~pulse:data_of_sqlite_column ~purity:data_of_sqlite_column ~racerd:data_of_sqlite_column ~lab_resource_leaks:data_of_sqlite_column ~scope_leakage:data_of_sqlite_column @@ -262,7 +263,7 @@ module SQLite = struct ; config_impact_analysis= load table ~proc_uid ConfigImpactAnalysis ; cost= load table ~proc_uid Cost ; disjunctive_demo= load table ~proc_uid DisjunctiveDemo - ; dispatch_once_static_init= load table ~proc_uid DispatchOnceStaticInit + ; static_constructor_stall_checker= load table ~proc_uid StaticConstructorStallChecker ; lab_resource_leaks= load table ~proc_uid LabResourceLeaks ; litho_required_props= load table ~proc_uid LithoRequiredProps ; pulse= load table ~proc_uid Pulse diff --git a/infer/src/backend/Payloads.mli b/infer/src/backend/Payloads.mli index 64eb308271..eb857a66a3 100644 --- a/infer/src/backend/Payloads.mli +++ b/infer/src/backend/Payloads.mli @@ -26,7 +26,7 @@ include sig ; config_impact_analysis: ConfigImpactAnalysis.Summary.t Lazy.t option ; cost: CostDomain.summary Lazy.t option ; disjunctive_demo: DisjunctiveDemo.domain Lazy.t option - ; dispatch_once_static_init: DispatchOnceStaticInit.Summary.t Lazy.t option + ; static_constructor_stall_checker: StaticConstructorStallChecker.Summary.t Lazy.t option ; lab_resource_leaks: ResourceLeakDomain.summary Lazy.t option ; litho_required_props: LithoDomain.summary Lazy.t option ; pulse: PulseSummary.t Lazy.t option diff --git a/infer/src/backend/registerCheckers.ml b/infer/src/backend/registerCheckers.ml index abc6b0e295..b3c5119282 100644 --- a/infer/src/backend/registerCheckers.ml +++ b/infer/src/backend/registerCheckers.ml @@ -91,9 +91,10 @@ let all_checkers = [ {checker= SelfInBlock; callbacks= [(intraprocedural SelfInBlock.checker, Clang)]} ; { checker= ParameterNotNullChecked ; callbacks= [(intraprocedural ParameterNotNullChecked.checker, Clang)] } - ; { checker= DispatchOnceStaticInit + ; { checker= StaticConstructorStallChecker ; callbacks= - [ ( interprocedural Payloads.Fields.dispatch_once_static_init DispatchOnceStaticInit.checker + [ ( interprocedural Payloads.Fields.static_constructor_stall_checker + StaticConstructorStallChecker.checker , Clang ) ] } ; { checker= BufferOverrunAnalysis ; callbacks= diff --git a/infer/src/base/Checker.ml b/infer/src/base/Checker.ml index d8b4feea24..3f1c0e7ec8 100644 --- a/infer/src/base/Checker.ml +++ b/infer/src/base/Checker.ml @@ -17,7 +17,7 @@ type t = | ConfigImpactAnalysis | Cost | DisjunctiveDemo - | DispatchOnceStaticInit + | StaticConstructorStallChecker | FragmentRetainsView | Impurity | InefficientKeysetIterator @@ -175,9 +175,9 @@ let config_unsafe checker = ; cli_flags= Some {deprecated= []; show_in_help= false} ; enabled_by_default= false ; activates= [] } - | DispatchOnceStaticInit -> - { id= "dispatch-once-static-init" - ; kind= UserFacing {title= "dispatch-once in static init"; markdown_body= ""} + | StaticConstructorStallChecker -> + { id= "static-constructor-stall-checker" + ; kind= UserFacing {title= "Static Constructor Stall Checker"; markdown_body= ""} ; support= mk_support_func ~clang:Support () ; short_documentation= "Detect if dispatch_once is called from a static constructor." ; cli_flags= Some {deprecated= []; show_in_help= true} diff --git a/infer/src/base/Checker.mli b/infer/src/base/Checker.mli index e577236131..9b2ff4898e 100644 --- a/infer/src/base/Checker.mli +++ b/infer/src/base/Checker.mli @@ -16,7 +16,7 @@ type t = | ConfigImpactAnalysis | Cost | DisjunctiveDemo - | DispatchOnceStaticInit + | StaticConstructorStallChecker | FragmentRetainsView | Impurity | InefficientKeysetIterator diff --git a/infer/src/base/IssueType.ml b/infer/src/base/IssueType.ml index 01270c27f7..2276652355 100644 --- a/infer/src/base/IssueType.ml +++ b/infer/src/base/IssueType.ml @@ -573,7 +573,7 @@ let deadlock = let dispatch_once_in_static_init = register ~category:Concurrency ~enabled:false ~id:"DISPATCH_ONCE_IN_STATIC_INIT" - ~hum:"dispatch_once in static init" Error DispatchOnceStaticInit + ~hum:"dispatch_once in static init" Error StaticConstructorStallChecker ~user_documentation: "Calling dispatch_once during the static initialization of objects is risky, for example it \ could cause deadlocks, because other objects might not have been initialized yet." diff --git a/infer/src/base/PayloadId.ml b/infer/src/base/PayloadId.ml index 94050f5b63..a63e371e67 100644 --- a/infer/src/base/PayloadId.ml +++ b/infer/src/base/PayloadId.ml @@ -15,7 +15,7 @@ type t = | ConfigImpactAnalysis | Cost | DisjunctiveDemo - | DispatchOnceStaticInit + | StaticConstructorStallChecker | LabResourceLeaks | LithoRequiredProps | Pulse @@ -46,8 +46,8 @@ let to_checker payload_id : Checker.t = Cost | DisjunctiveDemo -> DisjunctiveDemo - | DispatchOnceStaticInit -> - DispatchOnceStaticInit + | StaticConstructorStallChecker -> + StaticConstructorStallChecker | LabResourceLeaks -> ResourceLeakLabExercise | LithoRequiredProps -> diff --git a/infer/src/base/PayloadId.mli b/infer/src/base/PayloadId.mli index 7097df0fd0..5a0564fa0f 100644 --- a/infer/src/base/PayloadId.mli +++ b/infer/src/base/PayloadId.mli @@ -16,7 +16,7 @@ type t = | ConfigImpactAnalysis | Cost | DisjunctiveDemo - | DispatchOnceStaticInit + | StaticConstructorStallChecker | LabResourceLeaks | LithoRequiredProps | Pulse diff --git a/infer/src/checkers/DispatchOnceStaticInit.ml b/infer/src/checkers/StaticConstructorStallChecker.ml similarity index 97% rename from infer/src/checkers/DispatchOnceStaticInit.ml rename to infer/src/checkers/StaticConstructorStallChecker.ml index 278d8c8623..4871faf048 100644 --- a/infer/src/checkers/DispatchOnceStaticInit.ml +++ b/infer/src/checkers/StaticConstructorStallChecker.ml @@ -87,7 +87,7 @@ let report_issue proc_desc err_log trace_elems = a deadlock." (kind_to_string kind) Location.pp loc in - Reporting.log_issue proc_desc err_log ~ltr ~loc DispatchOnceStaticInit + Reporting.log_issue proc_desc err_log ~ltr ~loc StaticConstructorStallChecker IssueType.dispatch_once_in_static_init message diff --git a/infer/src/checkers/DispatchOnceStaticInit.mli b/infer/src/checkers/StaticConstructorStallChecker.mli similarity index 100% rename from infer/src/checkers/DispatchOnceStaticInit.mli rename to infer/src/checkers/StaticConstructorStallChecker.mli diff --git a/infer/tests/codetoanalyze/objc/dispatch-once-static-init/issues.exp b/infer/tests/codetoanalyze/objc/dispatch-once-static-init/issues.exp deleted file mode 100644 index 4b90b0ee96..0000000000 --- a/infer/tests/codetoanalyze/objc/dispatch-once-static-init/issues.exp +++ /dev/null @@ -1,3 +0,0 @@ -codetoanalyze/objc/dispatch-once-static-init/DispatchOnceInStaticInit.m, initializer_test_interproc_bad, 1, DISPATCH_ONCE_IN_STATIC_INIT, no_bucket, ERROR, [Call to Manager.getInstance,macro expanded here,Call to _dispatch_once] -codetoanalyze/objc/dispatch-once-static-init/DispatchOnceInStaticInit.m, initializer_test_intraproc_bad, 3, DISPATCH_ONCE_IN_STATIC_INIT, no_bucket, ERROR, [macro expanded here,Call to _dispatch_once] -codetoanalyze/objc/dispatch-once-static-init/DispatchOnceInStaticInit.m, initializer_test_interproc_condition_bad, 3, DISPATCH_ONCE_IN_STATIC_INIT, no_bucket, ERROR, [Call to Manager.getInstance,macro expanded here,Call to _dispatch_once] diff --git a/infer/tests/codetoanalyze/objc/dispatch-once-static-init/DispatchOnceInStaticInit.m b/infer/tests/codetoanalyze/objc/static-constructor-stall/DispatchOnceInStaticInit.m similarity index 100% rename from infer/tests/codetoanalyze/objc/dispatch-once-static-init/DispatchOnceInStaticInit.m rename to infer/tests/codetoanalyze/objc/static-constructor-stall/DispatchOnceInStaticInit.m diff --git a/infer/tests/codetoanalyze/objc/dispatch-once-static-init/Makefile b/infer/tests/codetoanalyze/objc/static-constructor-stall/Makefile similarity index 84% rename from infer/tests/codetoanalyze/objc/dispatch-once-static-init/Makefile rename to infer/tests/codetoanalyze/objc/static-constructor-stall/Makefile index 5a5f532097..3aed328aad 100644 --- a/infer/tests/codetoanalyze/objc/dispatch-once-static-init/Makefile +++ b/infer/tests/codetoanalyze/objc/static-constructor-stall/Makefile @@ -6,7 +6,7 @@ TESTS_DIR = ../../.. CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) -fobjc-arc -INFER_OPTIONS = --dispatch-once-static-init-only --debug-exceptions --project-root $(TESTS_DIR) +INFER_OPTIONS = --static-constructor-stall-checker-only --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = \ --issues-tests-fields file,procedure,line_offset,bug_type,bucket,severity,bug_trace,taint_extra,transitive_callees_extra,autofix \ --issues-tests diff --git a/infer/tests/codetoanalyze/objc/static-constructor-stall/issues.exp b/infer/tests/codetoanalyze/objc/static-constructor-stall/issues.exp new file mode 100644 index 0000000000..e65683accf --- /dev/null +++ b/infer/tests/codetoanalyze/objc/static-constructor-stall/issues.exp @@ -0,0 +1,3 @@ +codetoanalyze/objc/static-constructor-stall/DispatchOnceInStaticInit.m, initializer_test_interproc_bad, 1, DISPATCH_ONCE_IN_STATIC_INIT, no_bucket, ERROR, [Call to Manager.getInstance,macro expanded here,Call to _dispatch_once] +codetoanalyze/objc/static-constructor-stall/DispatchOnceInStaticInit.m, initializer_test_intraproc_bad, 3, DISPATCH_ONCE_IN_STATIC_INIT, no_bucket, ERROR, [macro expanded here,Call to _dispatch_once] +codetoanalyze/objc/static-constructor-stall/DispatchOnceInStaticInit.m, initializer_test_interproc_condition_bad, 3, DISPATCH_ONCE_IN_STATIC_INIT, no_bucket, ERROR, [Call to Manager.getInstance,macro expanded here,Call to _dispatch_once]