Skip to content

Commit

Permalink
[static-ctor-stall] Changing the name of the checker
Browse files Browse the repository at this point in the history
Summary:
This is because the checker is about to become more generic, flagging other method calls in static constructors.

Will change the name of the issue type in the next diff.

Reviewed By: ngorogiannis

Differential Revision: D66710556

fbshipit-source-id: 293250b9d5850754b939fe444bea4b5a3492da10
  • Loading branch information
dulmarod authored and facebook-github-bot committed Dec 4, 2024
1 parent 1c28e93 commit 19264a6
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
21 changes: 11 additions & 10 deletions infer/man/man1/infer-analyze.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
25 changes: 13 additions & 12 deletions infer/man/man1/infer-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
25 changes: 13 additions & 12 deletions infer/man/man1/infer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions infer/src/backend/Payloads.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion infer/src/backend/Payloads.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions infer/src/backend/registerCheckers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
8 changes: 4 additions & 4 deletions infer/src/base/Checker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type t =
| ConfigImpactAnalysis
| Cost
| DisjunctiveDemo
| DispatchOnceStaticInit
| StaticConstructorStallChecker
| FragmentRetainsView
| Impurity
| InefficientKeysetIterator
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion infer/src/base/Checker.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type t =
| ConfigImpactAnalysis
| Cost
| DisjunctiveDemo
| DispatchOnceStaticInit
| StaticConstructorStallChecker
| FragmentRetainsView
| Impurity
| InefficientKeysetIterator
Expand Down
2 changes: 1 addition & 1 deletion infer/src/base/IssueType.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
6 changes: 3 additions & 3 deletions infer/src/base/PayloadId.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type t =
| ConfigImpactAnalysis
| Cost
| DisjunctiveDemo
| DispatchOnceStaticInit
| StaticConstructorStallChecker
| LabResourceLeaks
| LithoRequiredProps
| Pulse
Expand Down Expand Up @@ -46,8 +46,8 @@ let to_checker payload_id : Checker.t =
Cost
| DisjunctiveDemo ->
DisjunctiveDemo
| DispatchOnceStaticInit ->
DispatchOnceStaticInit
| StaticConstructorStallChecker ->
StaticConstructorStallChecker
| LabResourceLeaks ->
ResourceLeakLabExercise
| LithoRequiredProps ->
Expand Down
2 changes: 1 addition & 1 deletion infer/src/base/PayloadId.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type t =
| ConfigImpactAnalysis
| Cost
| DisjunctiveDemo
| DispatchOnceStaticInit
| StaticConstructorStallChecker
| LabResourceLeaks
| LithoRequiredProps
| Pulse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 19264a6

Please sign in to comment.