PageSourceSearch

https://fbinfer.com/assets/js/bf6aacca.bccceaa9.js

js fbinfer.com collected 2026-09-24 17:55:31 UTC 132,058 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[2212],{1927(e,n,i){i.r(n),i.d(n,{assets:()=>o,contentTitle:()=>l,default:()=>h,frontMatter:()=>t,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"all-issue-types","title":"List of all issue types","description":"Here is an overview of the issue types currently reported by Infer.","source":"@site/versioned_docs/version-1.1.0/all-issue-types.md","sourceDirName":".","slug":"/all-issue-types","permalink":"/docs/1.1.0/all-issue-types","draft":false,"unlisted":false,"tags":[],"version":"1.1.0","frontMatter":{"title":"List of all issue types"},"sidebar":"docs","previous":{"title":"infer run","permalink":"/docs/1.1.0/man-infer-run"},"next":{"title":"Annotation Reachability","permalink":"/docs/1.1.0/checker-annotation-reachability"}}');var s=i(4848),a=i(8453);const t={title:"List of all issue types"},l=void 0,o={},c=[{value:"ARBITRARY_CODE_EXECUTION_UNDER_LOCK",id:"arbitrary_code_execution_under_lock",level:2},{value:"ASSIGN_POINTER_WARNING",id:"assign_pointer_warning",level:2},{value:"AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE",id:"autoreleasepool_size_complexity_increase",level:2},{value:"AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE_UI_THREAD",id:"autoreleasepool_size_complexity_increase_ui_thread",level:2},{value:"AUTORELEASEPOOL_SIZE_UNREACHABLE_AT_EXIT",id:"autoreleasepool_size_unreachable_at_exit",level:2},{value:"BAD_POINTER_COMPARISON",id:"bad_pointer_comparison",level:2},{value:"BIABDUCTION_MEMORY_LEAK",id:"biabduction_memory_leak",level:2},{value:"BUFFER_OVERRUN_L1",id:"buffer_overrun_l1",level:2},{value:"BUFFER_OVERRUN_L2",id:"buffer_overrun_l2",level:2},{value:"BUFFER_OVERRUN_L3",id:"buffer_overrun_l3",level:2},{value:"BUFFER_OVERRUN_L4",id:"buffer_overrun_l4",level:2},{value:"BUFFER_OVERRUN_L5",id:"buffer_overrun_l5",level:2},{value:"BUFFER_OVERRUN_S2",id:"buffer_overrun_s2",level:2},{value:"BUFFER_OVERRUN_U5",id:"buffer_overrun_u5",level:2},{value:"CAPTURED_STRONG_SELF",id:"captured_strong_self",level:2},{value:"CHECKERS_ALLOCATES_MEMORY",id:"checkers_allocates_memory",level:2},{value:"CHECKERS_ANNOTATION_REACHABILITY_ERROR",id:"checkers_annotation_reachability_error",level:2},{value:"CHECKERS_CALLS_EXPENSIVE_METHOD",id:"checkers_calls_expensive_method",level:2},{value:"CHECKERS_EXPENSIVE_OVERRIDES_UNANNOTATED",id:"checkers_expensive_overrides_unannotated",level:2},{value:"CHECKERS_FRAGMENT_RETAINS_VIEW",id:"checkers_fragment_retains_view",level:2},{value:"CHECKERS_IMMUTABLE_CAST",id:"checkers_immutable_cast",level:2},{value:"CHECKERS_PRINTF_ARGS",id:"checkers_printf_args",level:2},{value:"COMPONENT_WITH_MULTIPLE_FACTORY_METHODS",id:"component_with_multiple_factory_methods",level:2},{value:"CONDITION_ALWAYS_FALSE",id:"condition_always_false",level:2},{value:"CONDITION_ALWAYS_TRUE",id:"condition_always_true",level:2},{value:"CONFIG_CHECKS_BETWEEN_MARKERS",id:"config_checks_between_markers",level:2},{value:"CONFIG_IMPACT",id:"config_impact",level:2},{value:"CONSTANT_ADDRESS_DEREFERENCE",id:"constant_address_dereference",level:2},{value:"CREATE_INTENT_FROM_URI",id:"create_intent_from_uri",level:2},{value:"CROSS_SITE_SCRIPTING",id:"cross_site_scripting",level:2},{value:"CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK",id:"cxx_reference_captured_in_objc_block",level:2},{value:"DANGLING_POINTER_DEREFERENCE",id:"dangling_pointer_dereference",level:2},{value:"DEADLOCK",id:"deadlock",level:2},{value:"DEAD_STORE",id:"dead_store",level:2},{value:"DIRECT_ATOMIC_PROPERTY_ACCESS",id:"direct_atomic_property_access",level:2},{value:"DISCOURAGED_WEAK_PROPERTY_CUSTOM_SETTER",id:"discouraged_weak_property_custom_setter",level:2},{value:"DIVIDE_BY_ZERO",id:"divide_by_zero",level:2},{value:"DOTNET_RESOURCE_LEAK",id:"dotnet_resource_leak",level:2},{value:"EMPTY_VECTOR_ACCESS",id:"empty_vector_access",level:2},{value:"ERADICATE_ANNOTATION_GRAPH",id:"eradicate_annotation_graph",level:2},{value:"ERADICATE_BAD_NESTED_CLASS_ANNOTATION",id:"eradicate_bad_nested_class_annotation",level:2},{value:"ERADICATE_CONDITION_REDUNDANT",id:"eradicate_condition_redundant",level:2},{value:"ERADICATE_FIELD_NOT_INITIALIZED",id:"eradicate_field_not_initialized",level:2},{value:"ERADICATE_FIELD_NOT_NULLABLE",id:"eradicate_field_not_nullable",level:2}
1,{value:"ERADICATE_FIELD_OVER_ANNOTATED",id:"eradicate_field_over_annotated",level:2},{value:"ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION",id:"eradicate_inconsistent_subclass_parameter_annotation",level:2},{value:"ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION",id:"eradicate_inconsistent_subclass_return_annotation",level:2},{value:"ERADICATE_META_CLASS_CAN_BE_NULLSAFE",id:"eradicate_meta_class_can_be_nullsafe",level:2},{value:"ERADICATE_META_CLASS_IS_NULLSAFE",id:"eradicate_meta_class_is_nullsafe",level:2},{value:"ERADICATE_META_CLASS_NEEDS_IMPROVEMENT",id:"eradicate_meta_class_needs_improvement",level:2},{value:"ERADICATE_NULLABLE_DEREFERENCE",id:"eradicate_nullable_dereference",level:2},{value:"ERADICATE_PARAMETER_NOT_NULLABLE",id:"eradicate_parameter_not_nullable",level:2},{value:"ERADICATE_REDUNDANT_NESTED_CLASS_ANNOTATION",id:"eradicate_redundant_nested_class_annotation",level:2},{value:"ERADICATE_RETURN_NOT_NULLABLE",id:"eradicate_return_not_nullable",level:2},{value:"ERADICATE_RETURN_OVER_ANNOTATED",id:"eradicate_return_over_annotated",level:2},{value:"ERADICATE_UNCHECKED_USAGE_IN_NULLSAFE",id:"eradicate_unchecked_usage_in_nullsafe",level:2},{value:"ERADICATE_UNVETTED_THIRD_PARTY_IN_NULLSAFE",id:"eradicate_unvetted_third_party_in_nullsafe",level:2},{value:"EXECUTION_TIME_COMPLEXITY_INCREASE",id:"execution_time_complexity_increase",level:2},{value:"EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD",id:"execution_time_complexity_increase_ui_thread",level:2},{value:"EXECUTION_TIME_UNREACHABLE_AT_EXIT",id:"execution_time_unreachable_at_exit",level:2},{value:"EXPENSIVE_AUTORELEASEPOOL_SIZE",id:"expensive_autoreleasepool_size",level:2},{value:"EXPENSIVE_EXECUTION_TIME",id:"expensive_execution_time",level:2},{value:"EXPENSIVE_LOOP_INVARIANT_CALL",id:"expensive_loop_invariant_call",level:2},{value:"EXPOSED_INSECURE_INTENT_HANDLING",id:"exposed_insecure_intent_handling",level:2},{value:"GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL",id:"global_variable_initialized_with_function_or_method_call",level:2},{value:"GUARDEDBY_VIOLATION",id:"guardedby_violation",level:2},{value:"GUARDEDBY_VIOLATION_NULLSAFE",id:"guardedby_violation_nullsafe",level:2},{value:"IMPURE_FUNCTION",id:"impure_function",level:2},{value:"INEFFICIENT_KEYSET_ITERATOR",id:"inefficient_keyset_iterator",level:2},{value:"INFERBO_ALLOC_IS_BIG",id:"inferbo_alloc_is_big",level:2},{value:"INFERBO_ALLOC_IS_NEGATIVE",id:"inferbo_alloc_is_negative",level:2},{value:"INFERBO_ALLOC_IS_ZERO",id:"inferbo_alloc_is_zero",level:2},{value:"INFERBO_ALLOC_MAY_BE_BIG",id:"inferbo_alloc_may_be_big",level:2},{value:"INFERBO_ALLOC_MAY_BE_NEGATIVE",id:"inferbo_alloc_may_be_negative",level:2},{value:"INFINITE_AUTORELEASEPOOL_SIZE",id:"infinite_autoreleasepool_size",level:2},{value:"INFINITE_EXECUTION_TIME",id:"infinite_execution_time",level:2},{value:"INSECURE_INTENT_HANDLING",id:"insecure_intent_handling",level:2},{value:"INTEGER_OVERFLOW_L1",id:"integer_overflow_l1",level:2},{value:"INTEGER_OVERFLOW_L2",id:"integer_overflow_l2",level:2},{value:"INTEGER_OVERFLOW_L5",id:"integer_overflow_l5",level:2},{value:"INTEGER_OVERFLOW_U5",id:"integer_overflow_u5",level:2},{value:"INTERFACE_NOT_THREAD_SAFE",id:"interface_not_thread_safe",level:2},{value:"INVARIANT_CALL",id:"invariant_call",level:2},{value:"IPC_ON_UI_THREAD",id:"ipc_on_ui_thread",level:2},{value:"IVAR_NOT_NULL_CHECKED",id:"ivar_not_null_checked",level:2},{value:"JAVASCRIPT_INJECTION",id:"javascript_injection",level:2},{value:"LAB_RESOURCE_LEAK",id:"lab_resource_leak",level:2},{value:"LOCKLESS_VIOLATION",id:"lockless_violation",level:2},{value:"LOCK_CONSISTENCY_VIOLATION",id:"lock_consistency_violation",level:2},{value:"Fixing Lock Consistency Violation reports",id:"fixing-lock-consistency-violation-reports",level:3},{value:"LOGGING_PRIVATE_DATA",id:"logging_private_data",level:2},{value:"MEMORY_LEAK",id:"memory_leak",level:2},{value:"Memory leak in C",id:"memory-leak-in-c",level:3},{value:"Memory leak in Objective-C",id:"memory-leak-in-objective-c",level:3},{value:"MISSING_REQUIRED_PROP",id:"missing_required_prop",level:2},{value:"MIXED_SELF_WEAKSELF",id:"mixed_self_weakself",level:2},{value:"MODIFIES_IMMUTABLE",id:"modifies_immutable",level:2},{value:"MULTIPLE_WEAKSELF",id:"multiple_weakself",level:2},{value:"MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE",id:"mutable_local_variable_in_component_file",level:2},{value:"NIL_MESSAGING_TO_NON_POD",id:"nil_messaging_to_non_pod",level:2},{value:"NULLPTR_DEREFERENCE",id:"nullptr_dereference",level:2},{value:"Null dereference in Java",id:"null-dereference-in-java",level:3},{value:"Null dereference in C",id:"null-dereference-in-c",level:3},{value:"Null dereference in Objective-C",id:"null-dereference-in-objective-c",level:3},{value:"NULL_DEREFERENCE",id:"null_dereference",level:2},{value:"OPTIONAL_EMPTY_ACCESS",id:"optional_empty_access",level:2},{value:"PARAMETER_NOT_NULL_CHECKED",id:"parameter_not_null_checked",level:2},{value:"POINTER_TO_CONST_OBJC_CLASS",id:"pointer_to_const_objc_class",level:2},{value:"PREMATURE_NIL_TERMINATION_ARGUMENT",id:"premature_nil_termination_argument",level:2},{value:"PULSE_UNINITIALIZED_VALUE",id:"pulse_uninitialized_value",level:2},{value:"PURE_FUNCTION",id:"pure_function",level:2}
1,{value:"QUANDARY_TAINT_ERROR",id:"quandary_taint_error",level:2},{value:"RESOURCE_LEAK",id:"resource_leak",level:2},{value:"Resource leak in C",id:"resource-leak-in-c",level:3},{value:"Resource leak in Java",id:"resource-leak-in-java",level:3},{value:"Basics and Standard Idiom",id:"basics-and-standard-idiom",level:3},{value:"Multiple Resources Bugs",id:"multiple-resources-bugs",level:4},{value:"Nested_Allocations",id:"nested_allocations",level:3},{value:"Allocation of JSonParser and Cursor resources",id:"allocation-of-jsonparser-and-cursor-resources",level:3},{value:"Escaping resources and exceptions",id:"escaping-resources-and-exceptions",level:3},{value:"Java 7's try-with-resources",id:"java-7s-try-with-resources",level:3},{value:"RETAIN_CYCLE",id:"retain_cycle",level:2},{value:"SHELL_INJECTION",id:"shell_injection",level:2},{value:"SHELL_INJECTION_RISK",id:"shell_injection_risk",level:2},{value:"SQL_INJECTION",id:"sql_injection",level:2},{value:"SQL_INJECTION_RISK",id:"sql_injection_risk",level:2},{value:"STACK_VARIABLE_ADDRESS_ESCAPE",id:"stack_variable_address_escape",level:2},{value:"STARVATION",id:"starvation",level:2},{value:"STATIC_INITIALIZATION_ORDER_FIASCO",id:"static_initialization_order_fiasco",level:2},{value:"STRICT_MODE_VIOLATION",id:"strict_mode_violation",level:2},{value:"STRONG_DELEGATE_WARNING",id:"strong_delegate_warning",level:2},{value:"STRONG_SELF_NOT_CHECKED",id:"strong_self_not_checked",level:2},{value:"THREAD_SAFETY_VIOLATION",id:"thread_safety_violation",level:2},{value:"Thread-safety: What is a data race",id:"thread-safety-what-is-a-data-race",level:3},{value:"Thread-safety: Potential fixes",id:"thread-safety-potential-fixes",level:3},{value:"Thread-safety: Conditions checked before reporting",id:"thread-safety-conditions-checked-before-reporting",level:3},{value:"Thread-safety: Thread annotations recognized by RacerD",id:"thread-safety-thread-annotations-recognized-by-racerd",level:3},{value:"Thread-safety: Other annotations and what they do",id:"thread-safety-other-annotations-and-what-they-do",level:3},{value:"THREAD_SAFETY_VIOLATION_NULLSAFE",id:"thread_safety_violation_nullsafe",level:2},{value:"TOPL_ERROR",id:"topl_error",level:2},{value:"UNINITIALIZED_VALUE",id:"uninitialized_value",level:2},{value:"UNREACHABLE_CODE",id:"unreachable_code",level:2},{value:"UNTRUSTED_BUFFER_ACCESS",id:"untrusted_buffer_access",level:2},{value:"UNTRUSTED_DESERIALIZATION",id:"untrusted_deserialization",level:2},{value:"UNTRUSTED_DESERIALIZATION_RISK",id:"untrusted_deserialization_risk",level:2},{value:"UNTRUSTED_ENVIRONMENT_CHANGE_RISK",id:"untrusted_environment_change_risk",level:2},{value:"UNTRUSTED_FILE",id:"untrusted_file",level:2},{value:"UNTRUSTED_FILE_RISK",id:"untrusted_file_risk",level:2},{value:"UNTRUSTED_HEAP_ALLOCATION",id:"untrusted_heap_allocation",level:2},{value:"UNTRUSTED_INTENT_CREATION",id:"untrusted_intent_creation",level:2},{value:"UNTRUSTED_URL_RISK",id:"untrusted_url_risk",level:2},{value:"UNTRUSTED_VARIABLE_LENGTH_ARRAY",id:"untrusted_variable_length_array",level:2},{value:"USER_CONTROLLED_SQL_RISK",id:"user_controlled_sql_risk",level:2},{value:"USE_AFTER_DELETE",id:"use_after_delete",level:2},{value:"USE_AFTER_FREE",id:"use_after_free",level:2},{value:"USE_AFTER_LIFETIME",id:"use_after_lifetime",level:2},{value:"VECTOR_INVALIDATION",id:"vector_invalidation",level:2},{value:"WEAK_SELF_IN_NO_ESCAPE_BLOCK",id:"weak_self_in_no_escape_block",level:2}];function d(e){const n={a:"a",code:"code",em:"em",h2:"h2",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.p,{children:"Here is an overview of the issue types currently reported by Infer."}),"\n",(0,s.jsx)(n.h2,{id:"arbitrary_code_execution_under_lock",children:"ARBITRARY_CODE_EXECUTION_UNDER_LOCK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Arbitrary Code Execution Under lock" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-starvation",children:"starvation"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"A call which may execute arbitrary code (such as registered, or chained, callbacks) is made while a lock 
1is held.\nThis code may deadlock whenever the callbacks obtain locks themselves, so it is an unsafe pattern.\nThis warning is issued only at the innermost lock acquisition around the final call."}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"public class NotUnderLock {\n  SettableFuture future = null;\n\n  public void callFutureSetOk() {\n    future.set(null);\n  }\n\n  public synchronized void firstAcquisitionBad() {\n    callFutureSetOk();\n  }\n\n  public void secondAcquisitionOk(Object o) {\n    synchronized (o) {\n      firstAcquisitionBad();\n    }\n  }\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"assign_pointer_warning",children:"ASSIGN_POINTER_WARNING"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Assign Pointer Warning" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This check fires when a pointer to an Obj-C object is tagged with an ",(0,s.jsx)(n.code,{children:"assign"}),"\nproperty (similar to the ",(0,s.jsx)(n.code,{children:"-Warc-unsafe-retained-assign"})," compiler flag). Not\nholding a strong reference to the object makes it easy to accidentally create\nand use a dangling pointer."]}),"\n",(0,s.jsx)(n.h2,{id:"autoreleasepool_size_complexity_increase",children:"AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Autoreleasepool Size Complexity Increase" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"[EXPERIMENTAL] Infer reports this issue when the ObjC autoreleasepool's size complexity of a\nprogram increases in degree: e.g. from constant to linear or from logarithmic to quadratic. This\nissue type is only reported in differential mode: i.e when we are comparing the analysis results of\ntwo runs of infer on a file."}),"\n",(0,s.jsx)(n.h2,{id:"autoreleasepool_size_complexity_increase_ui_thread",children:"AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE_UI_THREAD"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Autoreleasepool Size Complexity Increase Ui Thread" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["[EXPERIMENTAL] Infer reports this issue when the ObjC autoreleasepool's complexity of the\nprocedure increases in degree ",(0,s.jsx)(n.strong,{children:"and"})," the procedure runs on the UI (main) thread."]}),"\n",(0,s.jsx)(n.p,{children:"Infer considers a method as running on the UI thread whenever:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["The method, one of its overrides, its class, or an ancestral class, is annotated with ",(0,s.jsx)(n.code,{children:"@UiThread"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["The method, or one of its overrides is annotated with ",(0,s.jsx)(n.code,{children:"@OnEvent"}),", ",(0,s.jsx)(n.code,{children:"@OnClick"}),", etc."]}),"\n",(0,s.jsxs)(n.li,{children:["The method or its callees call a ",(0,s.jsx)(n.code,{children:"Litho.ThreadUtils"})," method such as ",(0,s.jsx)(n.code,{children:"assertMainThread"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"autoreleasepool_size_unreachable_at_exit",children:"AUTORELEASEPOOL_SIZE_UNREACHABLE_AT_EXIT"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Autoreleasepool Size Unreachable At Exit" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"[EXPERIMENTAL] This issue type indicates that the program's execution doesn't reach the exit\nnode. Hence, we cannot compute a static bound of ObjC autoreleasepool's size for the procedure."}),"\n",(0,s.jsx)(n.h2,{id:"bad_pointer_comparison",children:"BAD_POINTER_COMPARISON"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Bad Pointer Comparison" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Infer reports these warnings in Objective-C when a boxed primitive type such as\n",(0,s.jsx)(n.code,{children:"NSNumber *"})," is coerced to a boolean in a comparison. For example, consider the\ncode"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:"void foo(NSNumber * n) {\n  if (n) ...\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The branch in the above code will be taken when the pointer ",(0,s.jsx)(n.code,{children:"n"})," is non-",(0,s.jsx)(n.code,{children:"nil"}),",\nbut the programmer might have actually wanted the branch to be taken when the\ninteger pointed to by ",(0,s.jsx)(n.code,{children:"n"})," is nonzero (e.g., she may have meant to call an\naccessor like ",(0,s.jsx)(n.code,{children:"[n intValue]"})," instead). Infer will ask the programmer explicitly\ncompare ",(0,s.jsx)(n.code,{children:"n"})," to ",(0,s.jsx)(n.code,{children:"nil"})," or call an accessor to clarify her intention."]}),"\n",(0,s.jsx)(n.h2,{id:"biabduction_memory_leak",children:"BIABDUCTION_MEMORY_LEAK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Memory Leak" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#memory_leak",children:"MEMORY_LEAK"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"buffer_overrun_l1",children:"BUFFER_OVERRUN_L1"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Buffer Overrun L1" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsx)(n.p,{children:'Buffer overrun reports fall into several "buckets" corresponding to the expected precision of the\nreport.  The higher the number, the more likely it is to be a false positive.'}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"L1"}),": The most faithful report, when it ",(0,s.jsx)(n.em,{children:"must"})," be unsafe.  For example, array size: ",(0,s.jsx)(n.code,{children:"[5,5]"}),",\noffset: ",(0,s.jsx)(n.code,{children:"[3,3]"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"L2"}),": Less faithful report than ",(0,s.jsx)(n.code,{children:"L1"}),", when it ",(0,s.jsx)(n.em,{children:"may"})," be unsafe.  For example, array size:",(0,s.jsx)(n.code,{children:"[5,5]"}),",\noffset: ",(0,s.jsx)(n.code,{children:"[0,5]"}),".  Note that the offset may be a safe value in the real execution, i.e. 0, 1, 2,\n3, 4."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"L5"}),": The least faithful report, when there is an interval top.  For example, array size:\n",(0,s.jsx)(n.code,{children:"[5,5]"}),", offset: ",(0,s.jsx)(n.code,{children:"[-oo,+oo]"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"L4"}),": More faithful report than ",(0,s.jsx)(n.code,{children:"L5"}),", when there is an infinity value.  For example, array size:\n",(0,s.jsx)(n.code,{children:"[5,5]"}
1),", offset: ",(0,s.jsx)(n.code,{children:"[0, +oo]"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"L3"}),": The reports that are not included in the above cases."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"S2"}),": An array access is unsafe by symbolic values.  For example, array size: ",(0,s.jsx)(n.code,{children:"[n,n]"}),", offset\n",(0,s.jsx)(n.code,{children:"[n,+oo]"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"U5"}),": An array access is unsafe by unknown values, which are usually from unknown function\ncalls."]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"buffer_overrun_l2",children:"BUFFER_OVERRUN_L2"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Buffer Overrun L2" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#buffer_overrun_l1",children:"BUFFER_OVERRUN_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"buffer_overrun_l3",children:"BUFFER_OVERRUN_L3"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Buffer Overrun L3" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#buffer_overrun_l1",children:"BUFFER_OVERRUN_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"buffer_overrun_l4",children:"BUFFER_OVERRUN_L4"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Buffer Overrun L4" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#buffer_overrun_l1",children:"BUFFER_OVERRUN_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"buffer_overrun_l5",children:"BUFFER_OVERRUN_L5"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Buffer Overrun L5" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#buffer_overrun_l1",children:"BUFFER_OVERRUN_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"buffer_overrun_s2",children:"BUFFER_OVERRUN_S2"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Buffer Overrun S2" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#buffer_overrun_l1",children:"BUFFER_OVERRUN_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"buffer_overrun_u5",children:"BUFFER_OVERRUN_U5"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Buffer Overrun U5" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#buffer_overrun_l1",children:"BUFFER_OVERRUN_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"captured_strong_self",children:"CAPTURED_STRONG_SELF"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Captured strongSelf" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-self-in-block",children:"self-in-block"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This will happen in one of two cases generally:"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["One uses ",(0,s.jsx)(n.code,{children:"weakSelf"})," but forgot to declare it weak first."]}),"\n",(0,s.jsxs)(n.li,{children:["One is using ",(0,s.jsx)(n.code,{children:"strongSelf"}),", declared in a block, in another (inside) block.\nThis changes the delicate balance of the ",(0,s.jsx)(n.code,{children:"weakSelf"}),"/",(0,s.jsx)(n.code,{children:"strongSelf"})," use in the\nfirst block. The retain cycle is avoided there because ",(0,s.jsx)(n.code,{children:"strongSelf"})," is a\nlocal variable to the block. If ",(0,s.jsx)(n.code,{children:"strongSelf"})," is used in the inside block,\nthen it's not a local variable anymore, but a captured variable."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"checkers_allocates_memory",children:"CHECKERS_ALLOCATES_MEMORY"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Allocates Memory" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-annotation-reachability",children:"annotation-reachability"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A method annotated with ",(0,s.jsx)(n.code,{children:"@NoAllocation"})," transitively calls ",(0,s.jsx)(n.code,{children:"new"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"class C implements I {\n  @NoAllocation\n  void directlyAllocatingMethod() {\n    new Object();\n  }\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"checkers_annotation_reachability_error",children:"CHECKERS_ANNOTATION_REACHABILITY_ERROR"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Annotation Reachability Error" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-annotation-reachability",children:"annotation-reachability"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A method annotated with an annotation ",(0,s.jsx)(n.code,{children:"@A"})," transitively calls a method annotated ",(0,s.jsx)(n.code,{children:"@B"})," where the combination of annotations is forbidden (for example, ",(0,s.jsx)(n.code,{children:"@UiThread"})," calling ",(0,s.jsx)(n.code,{children:"@WorkerThread"}),")."]}),"\n",(0,s.jsx)(n.h2,{id:"checkers_calls_expensive_method",children:"CHECKERS_CALLS_EXPENSIVE_METHOD"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Expensive Method Called" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-annotation-reachability",children:"annotation-reachability"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A method annotated with ",(0,s.jsx)(n.code,{children:"@PerformanceCritical"})," transitively calls a method annotated ",(0,s.jsx)(n.code,{children:"@Expensive"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"class C {\n  @PerformanceCritical\n  void perfCritical() {\n    expensive();\n  }\n\n  @Expensive\n  void expensive() {}\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"checkers_expensive_overrides_unannotated",children:"CHECKERS_EXPENSIVE_OVERRIDES_UNANNOTATED"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Expensive Overrides Unannotated" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-annotation-reachability",children:"annotation-reachability"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A method annotated with ",(0,s.jsx)(n.code,{children:"@Expensive"})," overrides an un-annotated method."]}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"interface I {\n  void foo();\n}\n\nclass A implements I {\n  @Expensive\n  public void foo() {}\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"checkers_fragment_retains_view",children:"CHECKERS_FRAGMENT_RETAINS_VIEW"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Fragment Retains View" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-fragment-retains-view",children:"fragment-retains-view"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This error type is Android-specific. It fires when a ",(0,s.jsx)(n.code,{children:"Fragment"})," type fails to\nnullify one or more of its declared ",(0,s.jsx)(n.code,{children:"View"})," fields in ",(0,s.jsx)(n.code,{children:"onDestroyView"}),". In\nperformance-sensitive applications, a ",(0,s.jsx)(n.code,{children:"Fragment"})," should initialize all ",(0,s.jsx)(n.code,{children:"View"}),"'s\nin ",(0,s.jsx)(n.code,{children:"onCreateView"})," and nullify them in ",(0,s.jsx)(n.code,{children:"onDestroyView"}),". If a ",(0,s.jsx)(n.code,{children:"Fragment"})," is placed\non the back stack and fails to nullify a ",(0,s.jsx)(n.code,{children:"View"})," in ",(0,s.jsx)(n.code,{children:"onDestroyView"}),", it will\nretain a useless reference to that ",(0,s.jsx)(n.code,{children:"View"})," that will not be cleaned up until the\n",(0,s.jsx)(n.code,{children:"Fragment"})," is resumed or destroyed."]}),"\n",(0,s.jsxs)(n.p,{children:["Action: Nullify the ",(0,s.jsx)(n.code,{children:"View"})," in question in ",(0,s.jsx)(n.code,{children:"onDestroyView"}),"."]}
1),"\n",(0,s.jsx)(n.h2,{id:"checkers_immutable_cast",children:"CHECKERS_IMMUTABLE_CAST"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Checkers Immutable Cast" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-immutable-cast",children:"immutable-cast"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This error type is reported in Java. It fires when an immutable collection is\nreturned from a method whose type is mutable."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  public List<String> getSomeList() {\n    ImmutableList<String> l = foo(...);\n    return l;\n  }\n"})}),"\n",(0,s.jsxs)(n.p,{children:["This can lead to a runtime error if users of ",(0,s.jsx)(n.code,{children:"getSomeList"})," try to modify the\nlist e.g. by adding elements."]}),"\n",(0,s.jsx)(n.p,{children:"Action: you can change the return type to be immutable, or make a copy of the\ncollection so that it can be modified."}),"\n",(0,s.jsx)(n.h2,{id:"checkers_printf_args",children:"CHECKERS_PRINTF_ARGS"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Checkers Printf Args" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-printf-args",children:"printf-args"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This error is reported when the argument types to a ",(0,s.jsx)(n.code,{children:"printf"})," method do not match the format string."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  void stringInsteadOfInteger(PrintStream out) {\n    out.printf("Hello %d", "world");\n  }\n'})}),"\n",(0,s.jsx)(n.p,{children:"Action: fix the mismatch between format string and argument types."}),"\n",(0,s.jsx)(n.h2,{id:"component_with_multiple_factory_methods",children:"COMPONENT_WITH_MULTIPLE_FACTORY_METHODS"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Component With Multiple Factory Methods" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"condition_always_false",children:"CONDITION_ALWAYS_FALSE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Condition Always False" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A condition expression is ",(0,s.jsx)(n.strong,{children:"always"}
1)," evaluated to false."]}),"\n",(0,s.jsx)(n.h2,{id:"condition_always_true",children:"CONDITION_ALWAYS_TRUE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Condition Always True" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A condition expression is ",(0,s.jsx)(n.strong,{children:"always"})," evaluated to true."]}),"\n",(0,s.jsx)(n.h2,{id:"config_checks_between_markers",children:"CONFIG_CHECKS_BETWEEN_MARKERS"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Config Checks Between Markers" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-config-checks-between-markers",children:"config-checks-between-markers"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"A config checking is done between a marker's start and end"}),"\n",(0,s.jsx)(n.h2,{id:"config_impact",children:"CONFIG_IMPACT"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Config Impact" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-config-impact-analysis",children:"config-impact-analysis"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"A function is called without a config check"}),"\n",(0,s.jsx)(n.h2,{id:"constant_address_dereference",children:"CONSTANT_ADDRESS_DEREFERENCE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Constant Address Dereference" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This is reported when an address obtained via a non-zero constant is\ndereferenced. If the address is zero then\n",(0,s.jsx)(n.a,{href:"#nullptr_dereference",children:(0,s.jsx)(n.code,{children:"NULLPTR_DEREFERENCE"})})," is reported instead."]}),"\n",(0,s.jsxs)(n.p,{children:["For example, ",(0,s.jsx)(n.code,{children:"int *p = (int *) 123; *p = 42;"})," generates this issue\ntype."]}),"\n",(0,s.jsx)(n.h2,{id:"create_intent_from_uri",children:"CREATE_INTENT_FROM_URI"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Create Intent From Uri" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Create an intent/start a component using a (possibly user-controlled) URI. may or may not be an issue depending on where the URI comes from."}),"\n",(0,s.jsx)(n.h2,{id:"cross_site_scripting",children:"CROSS_SITE_SCRIPTING"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Cross Site Scripting" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted data flows into HTML; XSS risk."}),"\n",(0,s.jsx)(n.h2,{id:"cxx_reference_captured_in_objc_block",children:"CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Cxx Reference Captured In Objc Block" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"With this check, Infer detects C++ references captured in a block. Doing this is\nalmost always wrong. The reason is that C++ references are not managed pointers\n(like ARC pointers) and so the referent is likely to be gone by the time the\nblock gets executed. One solution is to do a local copy of the reference and\npass that to the block. Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-c",children:"(int &) v;\n...\nconst int copied_v = v;\n^{\n// use copied_v not v\n};\n"})}),"\n",(0,s.jsx)(n.h2,{id:"dangling_pointer_dereference",children:"DANGLING_POINTER_DEREFERENCE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Dangling Pointer Dereference" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"deadlock",children:"DEADLOCK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Deadlock" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-starvation",children:"starvation"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This error is currently reported in Java. A deadlock occurs when two distinct\nthreads try to acquire two locks in reverse orders. The following code\nillustrates a textbook example. Of course, in real deadlocks, the lock\nacquisitions may be separated by deeply nested call chains."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  public void lockAThenB() {\n    synchronized(lockA) {\n      synchronized(lockB) {\n       // do s
1omething with both resources\n      }\n    }\n  }\n\n  public void lockBThenA() {\n    synchronized(lockB) {\n      synchronized(lockA) {\n       // do something with both resources\n      }\n    }\n  }\n"})}),"\n",(0,s.jsx)(n.p,{children:"The standard solution to a deadlock is to fix an order of lock acquisition and\nadhere to that order in all cases. Another solution may be to shrink the\ncritical sections (i.e., the code executing under lock) to the minimum required."}),"\n",(0,s.jsxs)(n.p,{children:["Old-style containers such as ",(0,s.jsx)(n.code,{children:"Vector"})," are synchronized on the object monitor,\nwhich means that deadlocks can occur even without explicit synchronisation on\nboth threads. For instance:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  public void lockAThenAddToVector() {\n    synchronized(lockA) {\n      vector.add(object);\n    }\n  }\n\n  public void lockVectorThenA() {\n    synchronized(vector) {\n      synchronized(lockA) {\n       // do something with both resources\n      }\n    }\n  }\n"})}),"\n",(0,s.jsx)(n.p,{children:"Infer has support for detecting these deadlocks too."}),"\n",(0,s.jsxs)(n.p,{children:["To suppress reports of deadlocks in a method ",(0,s.jsx)(n.code,{children:"m()"})," use the\n",(0,s.jsx)(n.code,{children:'@SuppressLint("DEADLOCK")'})," annotation, as follows:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  import android.annotation.SuppressLint;\n\n  @SuppressLint("DEADLOCK")\n  public void m() {\n  ...\n  }\n'})}),"\n",(0,s.jsx)(n.h2,{id:"dead_store",children:"DEAD_STORE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Dead Store" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-liveness",children:"liveness"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This error is reported in C++. It fires when the value assigned to a variables\nis never used (e.g., ",(0,s.jsx)(n.code,{children:"int i = 1; i = 2; return i;"}),")."]}),"\n",(0,s.jsx)(n.h2,{id:"direct_atomic_property_access",children:"DIRECT_ATOMIC_PROPERTY_ACCESS"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Direct Atomic Property Access" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This check warns you when you are accessing an atomic property directly with an\nivar. This makes the atomic property not atomic anymore. So potentially you may\nget a race condition."}),"\n",(0,s.jsx)(n.p,{children:"To fix the problem you need to access properties with their getter or setter."}),"\n",(0,s.jsx)(n.h2,{id:"discouraged_weak_property_custom_setter",children:"DISCOURAGED_WEAK_PROPERTY_CUSTOM_SETTER"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Discouraged Weak Property Custom Setter" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This check warns you when you have a custom setter for a weak property. When\ncompiled with Automatic Reference Counting (ARC, ",(0,s.jsx)(n.code,{children:"-fobj-arc"}),") ARC may set the\nproperty to ",(0,s.jsx)(n.code,{children:"nil"})," without invoking the setter, for example:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:'#import <Foundation/Foundation.h>\n\n@interface Employee : NSObject {\n  NSString* _name;\n  __weak Employee* _manager;\n}\n-(id)initWithName:(NSString*)name;\n@property(atomic, weak) Employee* manager;\n-(void)report;\n@end\n\n@implementation Employee\n\n-(id)initWithName:(NSString*)name {\n  _name = name;\n  return self;\n}\n\n-(NSString*)description {\n  return _name;\n}\n\n-(void)report {\n  NSLog(@"I work for %@", _manager);\n}\n\n-(Employee*)manager {\n  return _manager;\n}\n\n// DON\'T do this; ARC will not call this when setting _manager to nil.\n-(void)setManager:(Employee*)newManager {\n  NSLog(@"Meet the new boss...");\n  _manager = newManager;\n}\n\n@end\n\nint main(int argc, char *argv[])\n{\n  Employee* bob = [[Employee alloc] initWithName:@"Bob"];\n  Employee* sue = [[Employee alloc] initWithName:@"Sue"];\n  bob.manager = sue;\n  [bob report];\n  sue = nil;\n  [bob report];\n  return 0;\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"This prints:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Meet the new boss...\nI work for Sue\nI work for (null)\n"})}),"\n",(0,s.jsx)(n.p,{children:"Note that the custom setter was only invoked once."}),"\n",(0,s.jsx)(n.h2,{id:"divide_by_zero",children:"DIVIDE_BY_ZERO"}
1),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Divide By Zero" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"dotnet_resource_leak",children:"DOTNET_RESOURCE_LEAK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Dotnet Resource Leak" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-dotnet-resource-leak",children:"dotnet-resource-leak"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Resource leak checker for .NET."}),"\n",(0,s.jsx)(n.h2,{id:"empty_vector_access",children:"EMPTY_VECTOR_ACCESS"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Empty Vector Access" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This error type is reported only in C++, in versions >= C++11."}),"\n",(0,s.jsx)(n.p,{children:"The code is trying to access an element of a vector that Infer believes to be\nempty. Such an access will cause undefined behavior at runtime."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-c++",children:"#include <vector>\nint foo(){\n  const std::vector<int> vec;\n  return vec[0]; // Empty vector access reported here\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_annotation_graph",children:"ERADICATE_ANNOTATION_GRAPH"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Annotation Graph" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_bad_nested_class_annotation",children:"ERADICATE_BAD_NESTED_CLASS_ANNOTATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "@Nullsafe annotation is inconsistent with outer class" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_condition_redundant",children:"ERADICATE_CONDITION_REDUNDANT"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Condition Redundant" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This report is inactive by default. Condition (x != null) or (x == null) when x\ncannot be null: the first condition is always true and the second is always\nfalse"}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'class C {\n  void m() {\n    String s = new String("abc");\n    if (s != null) {\n      int n = s.length();\n    }\n  }\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"Action: Make sure that the annotations are correct, as the condition is\nconsidered redundant based on the existing annotations. In particular, check the\nannotation of any input parameters and fields of the current method, as well as\nthe annotations of any method called directly by the current method, if\nrelevant. If the annotations are correct, you can remove the redundant case."}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_field_not_initialized",children:"ERADICATE_FIELD_NOT_INITIALIZED"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Field Not Initialized" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"The constructor does not initialize a field f which is not annotated with\n@Nullable"}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"class C {\n  String f;\n\n  C () { // field f not initialized and not annotated @Nullable\n  }\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"Action: The preferred action is to initialize the field with a value that is not\nnull. If, by design, null is a valid value for the field, then it should be\nannotated with @Nullable."}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_field_not_nullable",children:"ERADICATE_FIELD_NOT_NULLABLE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Field Not Nullable" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"An assignment x.f = v where v could be null and field f is not annotated with\n@Nullable."}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"class C {\n  String f;\n\n  void foo(@Nullable String s) {\n    f = s;\n  }\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"Action: The preferred action is to ensure that a null value is never stored in\nthe field, by changing the code or changing annotations. If this cannot be done,\nadd a @Nullable annotation to the field. This annotation might trigger more\nwarnings in other code that uses the field, as that code must now deal with null\nvalues."}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_field_over_annotated",children:"ERADICATE_FIELD_OVER_ANNOTATED"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Field Over Annotated" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_inconsistent_subclass_parameter_annotation",children:"ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Inconsistent Subclass Parameter Annotation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"A parameter of the overridden method is missing a @Nullable annotation present in the superclass."}),"\n",(0,s.jsx)(n.p,{children:"Action: choose a consistent annotation based on the desired invariant."}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"class A {\n\n  int len(@Nullable String s) {\n    if (s != null) {\n      return s.length();\n    } else {\n      return 0;\n    }\n  }\n}\n\nclass B extends A {\n\n  int len(String s) {  // @Nullable missing.\n    return s.length();\n  }\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"A consistent use of @Nullable on parameters across subtyping should prevent runtime issue like in:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"public class Main {\n\n  String s;\n\n  int foo() {\n    A a = new B();\n    return a.len(s);\n  }\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_inconsistent_subclass_return_annotation",children:"ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Inconsistent Subclass Return Annotation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"The return type of the overridden method is annotated @Nullable, but the\ncorresponding method in the superclass is not."}),"\n",(0,s.jsx)(n.p,{children:"Action: choose a consistent annotation based on the desired invariant."}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'class A {\n  String create() {\n    return new String("abc");\n  }\n}\n\nclass B extends A {\n  @Nullable String create() {  // Inconsistent @Nullable annotation.\n      return null;\n  }\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["A consistent use of ",(0,s.jsx)(n.code,{children:"@Nullable"})," on the return type across subtyping should prevent\nruntime issue like in:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"class Main {\n\n  int foo(A a) {\n     String s = a.create();\n     return s.length();\n  }\n\n  void main(String[] args) {\n     A a = new B();\n     foo(a);\n  }\n\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_meta_class_can_be_nullsafe",children:"ERADICATE_META_CLASS_CAN_BE_NULLSAFE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Class has 0 issues and can be marked @Nullsafe" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_meta_class_is_nullsafe",children:"ERADICATE_META_CLASS_IS_NULLSAFE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Class is marked @Nullsafe and has 0 issues" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_meta_class_needs_improvement",children:"ERADICATE_META_CLASS_NEEDS_IMPROVEMENT"}
1),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Class needs improvement to become @Nullsafe" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Reported when the class either:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"has at least one nullability issue, or"}),"\n",(0,s.jsxs)(n.li,{children:["has at least one (currently possibly hidden) issue preventing it from being marked ",(0,s.jsx)(n.code,{children:"@Nullsafe"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_nullable_dereference",children:"ERADICATE_NULLABLE_DEREFERENCE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Nullable Dereference" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_parameter_not_nullable",children:"ERADICATE_PARAMETER_NOT_NULLABLE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Parameter Not Nullable" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Method call x.m(..., v, ...) where v can be null and the corresponding parameter\nin method m is not annotated with @Nullable"}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"class C {\n  void m(C x) {\n    String s = x.toString()\n  }\n\n  void test(@Nullable C x) {\n    m(x);\n  }\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"Action: The preferred action is to ensure that a null value is never passed to\nthe method, by changing the code or changing annotations. If this cannot be\ndone, add a @Nullable annotation to the relevant parameter in the method\ndeclaration. This annotation might trigger more warnings in the implementation\nof method m, as that code must now deal with null values."}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_redundant_nested_class_annotation",children:"ERADICATE_REDUNDANT_NESTED_CLASS_ANNOTATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "@Nullsafe annotation is redundant" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_return_not_nullable",children:"ERADICATE_RETURN_NOT_NULLABLE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Return Not Nullable" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Method m can return null, but the method's return type is not annotated with\n@Nullable"}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"class C {\n  String m() {\n    return null;\n  }\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"Action: The preferred action is to ensure that a null value is never returned by\nthe method, by changing the code or changing annotations. If this cannot be\ndone, add a @Nullable annotation to the method declaration. This annotation\nmight trigger more warnings in the callers of method m, as the callers must now\ndeal with null values."}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_return_over_annotated",children:"ERADICATE_RETURN_OVER_ANNOTATED"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Return Over Annotated" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This report is inactive by default. Method m is annotated with @Nullable but the\nmethod cannot return null"}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'class C {\n  @Nullable String m() {\n    String s = new String("abc");\n    return s;\n  }\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"Action: Make sure that the annotations are correct, as the return annotation is\nconsidered redundant based on the existing annotations. In particular, check the\nannotation of any input parameters and fields of the current method, as well as\nthe annotations of any method called directly by the current method, if\nrelevant. If the annotations are correct, you can remove the @Nullable\nannotation."}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_unchecked_usage_in_nullsafe",children:"ERADICATE_UNCHECKED_USAGE_IN_NULLSAFE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Nullsafe mode: unchecked usage of a value" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"eradicate_unvetted_third_party_in_nullsafe",children:"ERADICATE_UNVETTED_THIRD_PARTY_IN_NULLSAFE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Nullsafe mode: unchecked usage of unvetted third-party" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-eradicate",children:"eradicate"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"execution_time_complexity_increase",children:"EXECUTION_TIME_COMPLEXITY_INCREASE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Execution Time Complexity Increase" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Infer reports this issue when the execution time complexity of a\nprogram increases in degree: e.g. from constant to linear or from\nlogarithmic to quadratic. This issue type is only reported in\ndifferential mode: i.e when we are comparing the analysis results of\ntwo runs of infer on a file."}),"\n",(0,s.jsx)(n.h2,{id:"execution_time_complexity_increase_ui_thread",children:"EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Execution Time Complexity Increase Ui Thread" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Infer reports this issue when the execution time complexity of the procedure increases in degree ",(0,s.jsx)(n.strong,{children:"and"})," the procedure runs on the UI (main) thread."]}),"\n",(0,s.jsx)(n.p,{children:"Infer considers a method as running on the UI thread whenever:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["The method, one of its overrides, its class, or an ancestral class, is\nannotated with ",(0,s.jsx)(n.code,{children:"@UiThread"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["The method, or one of its overrides is annotated with ",(0,s.jsx)(n.code,{children:"@OnEvent"}),", ",(0,s.jsx)(n.code,{children:"@OnClick"}),",\netc."]}),"\n",(0,s.jsxs)(n.li,{children:["The method or its callees call a ",(0,s.jsx)(n.code,{children:"Litho.ThreadUtils"})," method such as\n",(0,s.jsx)(n.code,{children:"assertMainThread"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"execution_time_unreachable_at_exit",children:"EXECUTION_TIME_UNREACHABLE_AT_EXIT"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Execution Time Unreachable At Exit" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This issue type indicates that the program's execution doesn't reach\nthe exit node. Hence, we cannot compute a static boun
1d for the\nprocedure."}),"\n",(0,s.jsx)(n.p,{children:"Examples:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"void exit_unreachable() {\n  exit(0); // modeled as unreachable\n}\n\n\nvoid infeasible_path_unreachable() {\n    Preconditions.checkState(false); // like assert false, state pruned to bottom\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"expensive_autoreleasepool_size",children:"EXPENSIVE_AUTORELEASEPOOL_SIZE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Expensive Autoreleasepool Size" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"[EXPERIMENTAL] This warning indicates that non-constant and non-top ObjC autoreleasepool's size in\nthe procedure.  By default, this issue type is disabled."}),"\n",(0,s.jsx)(n.h2,{id:"expensive_execution_time",children:"EXPENSIVE_EXECUTION_TIME"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Expensive Execution Time" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"[EXPERIMENTAL] This warning indicates that non-constant and non-top execution time complexity of\nthe procedure.  By default, this issue type is disabled."}),"\n",(0,s.jsx)(n.h2,{id:"expensive_loop_invariant_call",children:"EXPENSIVE_LOOP_INVARIANT_CALL"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Expensive Loop Invariant Call" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-loop-hoisting",children:"loop-hoisting"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["We report this issue type when a function is ",(0,s.jsx)(n.a,{href:"/docs/1.1.0/all-issue-types#invariant_call",children:"loop-invariant"})," and also expensive (i.e. at least has linear complexity as determined by the ",(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"})," analysis)."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"int incr(int x) {\n  return x + 1;\n}\n\n// incr will not be hoisted since it is cheap(constant time)\nvoid foo_linear(int size) {\n  int x = 10;\n  for (int i = 0; i < size; i++) {\n    incr(x); // constant call, don't hoist\n  }\n}\n\n// call to foo_linear will be hoisted since it is expensive(linear in size).\nvoid symbolic_expensive_hoist(int size) {\n  for (int i = 0; i < size; i++) {\n    foo_linear(size); // hoist\n  }\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"exposed_insecure_intent_handling",children:"EXPOSED_INSECURE_INTENT_HANDLING"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Exposed Insecure Intent Handling" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Undocumented."}),"\n",(0,s.jsx)(n.h2,{id:"global_variable_initialized_with_function_or_method_call",children:"GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Global Variable Initialized With Function Or Method Call" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This checker warns you when the initialization of global variable contain a\nmethod or function call. The warning wants to make you aware that some functions\nare expensive. As the global variables are initialized before main() is called,\nthese initializations can slow down the start-up time of an app."}),"\n",(0,s.jsx)(n.h2,{id:"guardedby_violation",children:"GUARDEDBY_VIOLATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "GuardedBy Violation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-racerd",children:"racerd"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A field annotated with ",(0,s.jsx)(n.code,{children:"@GuardedBy"})," is being accessed by a call-chain that starts at a non-private method without synchronization."]}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'class C {\n  @GuardedBy("this")\n  String f;\n\n  void foo(String s) {\n    f = s; // unprotected access here\n  }\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Action: Protect the offending access by acquiring the lock indicated by the ",(0,s.jsx)(n.code,{children:"@GuardedBy(...)"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"guardedby_violation_nullsafe",children:"GUARDEDBY_VIOLATION_NULLSAFE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "GuardedBy Violation in ',(0,s.jsx)(n.code,{children:"@Nullsafe"}),' Class" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-racerd",children:"racerd"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A field annotated with ",(0,s.jsx)(n.code,{children:"@GuardedBy"})," is being accessed by a call-chain that starts at a non-private method without synchronization."]}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'class C {\n  @GuardedBy("this")\n  Str
1ing f;\n\n  void foo(String s) {\n    f = s; // unprotected access here\n  }\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Action: Protect the offending access by acquiring the lock indicated by the ",(0,s.jsx)(n.code,{children:"@GuardedBy(...)"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"impure_function",children:"IMPURE_FUNCTION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Impure Function" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-impurity",children:"impurity"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This issue type indicates impure functions. For instance, below functions would be marked as impure:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"void makeAllZero_impure(ArrayList<Foo> list) {\n  Iterator<Foo> listIterator = list.iterator();\n  while (listIterator.hasNext()) {\n    Foo foo = listIterator.next();\n    foo.x = 0;\n  }\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"inefficient_keyset_iterator",children:"INEFFICIENT_KEYSET_ITERATOR"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Inefficient Keyset Iterator" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-inefficient-keyset-iterator",children:"inefficient-keyset-iterator"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This issue is raised when"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["iterating over a HashMap with ",(0,s.jsx)(n.code,{children:"keySet()"})," iterator"]}),"\n",(0,s.jsx)(n.li,{children:"looking up the key each time"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Instead, it is more efficient to iterate over the loop with ",(0,s.jsx)(n.code,{children:"entrySet"})," which returns key-vaue pairs and gets rid of the hashMap lookup.\nFor instance, we would raise an issue for the following program:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"void inefficient_loop_bad(HashMap<String, Integer> testMap) {\n for (String key : testMap.keySet()) {\n   Integer value = testMap.get(key); // extra look-up cost\n   foo(key, value);\n }\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"Instead, it is more efficient to have:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"void efficient_loop_ok(HashMap<String, Integer> testMap) {\n  for (Map.Entry<String, Integer> entry : testMap.entrySet()) {\n    String key = entry.getKey();\n    Integer value = entry.getValue();\n    foo(key, value);\n  }\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"inferbo_alloc_is_big",children:"INFERBO_ALLOC_IS_BIG"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Inferbo Alloc Is Big" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"malloc"})," is passed a large constant value."]}),"\n",(0,s.jsx)(n.h2,{id:"inferbo_alloc_is_negative",children:"INFERBO_ALLOC_IS_NEGATIVE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Inferbo Alloc Is Negative" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"malloc"})," is called with a negative size."]}),"\n",(0,s.jsx)(n.h2,{id:"inferbo_alloc_is_zero",children:"INFERBO_ALLOC_IS_ZERO"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Inferbo Alloc Is Zero" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"malloc"})," is called with a zero size."]}),"\n",(0,s.jsx)(n.h2,{id:"inferbo_alloc_may_be_big",children:"INFERBO_ALLOC_MAY_BE_BIG"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Inferbo Alloc May Be Big" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"malloc"})," ",(0,s.jsx)(n.em,{children:"may"})," be called with a large value."]}),"\n",(0,s.jsx)(n.h2,{id:"inferbo_alloc_may_be_negative",children:"INFERBO_ALLOC_MAY_BE_NEGATIVE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Inferbo Alloc May Be Negative" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"malloc"})," ",(0,s.jsx)(n.em,{children:"may"})," be called with a negative value."]}),"\n",(0,s.jsx)(n.h2,{id:"infinite_autoreleasepool_size",children:"INFINITE_AUTORELEASEPOOL_SIZE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Infinite Autoreleasepool Size" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"[EXPERIMENTAL] This warning indicates that Infer was not able to determine a static upper bound on\nthe ObjC autoreleasepool's size in the procedure. By default, this issue type is disabled."}),"\n",(0,s.jsx)(n.h2,{id:"infinite_execution_time",children:"INFINITE_EXECUTION_TIME"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Infinite Execution Time" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-cost",children:"cost"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This warning indicates that Infer was not able to determine a static\nupper bound on the execution cost of the procedure. By default, this\nissue type is disabled."}),"\n",(0,s.jsx)(n.p,{children:"For instance, Inferbo's interval analysis is limited to affine\nexpressions. Hence, we can't statically estimate an upper bound on the\nbelow example and obtain T(unknown) cost:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"// Expected: square root(x), got T\nvoid square_root_FP(int x) {\
1n int i = 0;\n while (i * i < x) {\n   i++;\n }\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Consequently, we report an ",(0,s.jsx)(n.code,{children:"INFINITE_EXECUTION_TIME"}),", corresponding to the biggest bound T."]}),"\n",(0,s.jsx)(n.h2,{id:"insecure_intent_handling",children:"INSECURE_INTENT_HANDLING"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Insecure Intent Handling" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Undocumented."}),"\n",(0,s.jsx)(n.h2,{id:"integer_overflow_l1",children:"INTEGER_OVERFLOW_L1"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Integer Overflow L1" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsx)(n.p,{children:'Integer overflows reports fall into several "buckets" corresponding to the expected precision of the\nreport. The higher the number, the more likely it is to be a false positive.'}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"L1"}),": The most faithful report, when it ",(0,s.jsx)(n.em,{children:"must"})," be unsafe.  For example,\n",(0,s.jsx)(n.code,{children:"[2147483647,2147483647] + [1,1]"})," in 32-bit signed integer type."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"L2"}),": Less faithful report than ",(0,s.jsx)(n.code,{children:"L1"}),", when it ",(0,s.jsx)(n.em,{children:"may"})," be unsafe.  For example,\n",(0,s.jsx)(n.code,{children:"[2147483647,2147483647] + [0,1]"})," in 32-bit signed integer type.  Note that the integer of RHS\ncan be 0, which is safe."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"L5"}),": The reports that are not included in the above cases."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"U5"}),": A binary integer operation is unsafe by unknown values, which are usually from unknown\nfunction calls."]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"integer_overflow_l2",children:"INTEGER_OVERFLOW_L2"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Integer Overflow L2" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#integer_overflow_l1",children:"INTEGER_OVERFLOW_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"integer_overflow_l5",children:"INTEGER_OVERFLOW_L5"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Integer Overflow L5" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#integer_overflow_l1",children:"INTEGER_OVERFLOW_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"integer_overflow_u5",children:"INTEGER_OVERFLOW_U5"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Integer Overflow U5" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#integer_overflow_l1",children:"INTEGER_OVERFLOW_L1"})]}),"\n",(0,s.jsx)(n.h2,{id:"interface_not_thread_safe",children:"INTERFACE_NOT_THREAD_SAFE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Interface Not Thread Safe" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-racerd",children:"racerd"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This error indicates that you have invoked an interface method not annotated\nwith ",(0,s.jsx)(n.code,{children:"@ThreadSafe"})," from a thread-safe context (e.g., code that uses locks or is\nmarked ",(0,s.jsx)(n.code,{children:"@ThreadSafe"}),"). The fix is to add the ",(0,s.jsx)(n.code,{children:"@ThreadSafe"})," annotation to the\ninterface or to the interface method. For background on why these annotations\nare needed, see the detailed explanation\n",(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-racerd#interface-not-thread-safe",children:"here"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"invariant_call",children:"INVARIANT_CALL"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Invariant Call" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-loop-hoisting",children:"loop-hoisting"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"We report this issue type when a function call is loop-invariant and hoistable, i.e."}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"the function has no side side effects (pure)"}),"\n",(0,s.jsx)(n.li,{children:"has invariant arguments and result (i.e. have the same value in all loop iterations)"}),"\n",(0,s.jsx)(n.li,{children:"it is guaranteed to execute, i.e. it dominates all loop sources"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"int foo(int x, int y) {\n return x + y;\n}\n\n\nvoid invariant_hoist(int size) {\n    int x = 10;\n    int y = 5;\n    for (int i = 0; i < size;
1 i++) {\n      foo(x, y); // hoistable\n    }\n  }\n"})}),"\n",(0,s.jsx)(n.h2,{id:"ipc_on_ui_thread",children:"IPC_ON_UI_THREAD"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Ipc On Ui Thread" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-starvation",children:"starvation"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A blocking ",(0,s.jsx)(n.code,{children:"Binder"})," IPC call occurs on the UI thread."]}),"\n",(0,s.jsx)(n.h2,{id:"ivar_not_null_checked",children:"IVAR_NOT_NULL_CHECKED"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Ivar Not Null Checked" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This error type is only reported in Objective-C. This is similar to Null\ndereference, but Infer hasn't found a whole trace where the error can happen,\nbut only found that a null dereference can happen if an instance variable of a\nparameter is ",(0,s.jsx)(n.code,{children:"nil"}),". For example:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:"  -(int) foo {\n      B *b = [self->_a foo]; // sending a message with receiver nil returns nil\n      return b->x; // dereferencing b, potential NPE if you pass nil as the argument a.\n  }\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Possible solutions are adding a check for ",(0,s.jsx)(n.code,{children:"nil"}),", or making sure that the method\nis not called with ",(0,s.jsx)(n.code,{children:"nil"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"javascript_injection",children:"JAVASCRIPT_INJECTION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Javascript Injection" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted data flows into JavaScript."}),"\n",(0,s.jsx)(n.h2,{id:"lab_resource_leak",children:"LAB_RESOURCE_LEAK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Lab Resource Leak" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-resource-leak-lab",children:"resource-leak-lab"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Toy issue."}),"\n",(0,s.jsx)(n.h2,{id:"lockless_violation",children:"LOCKLESS_VIOLATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Lockless Violation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-starvation",children:"starvation"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A method implements an interface signature annotated with ",(0,s.jsx)(n.code,{children:"@Lockless"})," but which transitively acquires a lock."]}),"\n",(0,s.jsx)(n.p,{children:"Example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"Interface I {\n    @Lockless\n    public void no_lock();\n}\n\nclass C implements I {\n  private synchronized do_lock() {}\n\n  public void no_lock() { // this method should not acquire any locks\n    do_lock();\n  }\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"lock_consistency_violation",children:"LOCK_CONSISTENCY_VIOLATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Lock Consistency Violation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-racerd",children:"racerd"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This is an error reported on C++ and Objective C classes whenever:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Some class method directly uses locking primitives (not transitively)."}),"\n",(0,s.jsxs)(n.li,{children:["It has a public method which writes to some member ",(0,s.jsx)(n.code,{children:"x"})," while holding a lock."]}),"\n",(0,s.jsxs)(n.li,{children:["It has a public method which reads ",(0,s.jsx)(n.code,{children:"x"})," without holding a lock."]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["The above may happen through a chain of calls. Above, ",(0,s.jsx)(n.code,{children:"x"})," may also be a\ncontainer (an array, a vector, etc)."]}),"\n",(0,s.jsx)(n.h3,{id:"fixing-lock-consistency-violation-reports",children:"Fixing Lock Consistency Violation reports"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Avoid the offending access (most often the read). Of course, this may not be\npossible."}),"\n",(0,s.jsx)(n.li,{children:"Use synchronization to protect the read, by using the same lock protecting the\ncorresponding write."}),"\n",(0,s.jsx)(n.li,{children:"Make the method doing the read access private. This should silence the\nwarning, since Infer looks for a pair of non-private methods. Objective-C:\nInfer considers a method as private if it's not exported in the header-file\ninterface."}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"logging_private_data",children:"LOGGING_PRIVATE_DATA"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Logging Private Data" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Undocumented."}),"\n",(0,s.jsx)(n.h2,{id:"memory_leak",children:"MEMORY_LEAK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Memory Leak" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"memory-leak-in-c",children:"Memory leak in C"}),"\n",(0,s.jsx)(n.p,{children:"This error type is only reported in C and Objective-C code. In Java we do not\nreport memory leaks because it is a garbage collected language."}),"\n",(0,s.jsxs)(n.p,{children:["In C, Infer reports memory leaks when objects are created with ",(0,s.jsx)(n.code,{children:"malloc"}
1)," and not\nfreed. For example:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-c",children:"-(void) memory_leak_bug {\n    struct Person *p = malloc(sizeof(struct Person));\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"memory-leak-in-objective-c",children:"Memory leak in Objective-C"}),"\n",(0,s.jsx)(n.p,{children:"Additionally, in Objective-C, Infer reports memory leaks that happen when\nobjects from Core Foundation or Core Graphics don't get released."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:"-(void) memory_leak_bug_cf {\n    CGPathRef shadowPath = CGPathCreateWithRect(self.inputView.bounds, NULL); //object created and not released.\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"missing_required_prop",children:"MISSING_REQUIRED_PROP"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Missing Required Prop" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-litho-required-props",children:"litho-required-props"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"As explained by the analysis."}),"\n",(0,s.jsx)(n.h2,{id:"mixed_self_weakself",children:"MIXED_SELF_WEAKSELF"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Mixed Self WeakSelf" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-self-in-block",children:"self-in-block"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This happens when an Objective-C block captures both ",(0,s.jsx)(n.code,{children:"self"})," and ",(0,s.jsx)(n.code,{children:"weakSelf"}),", a\nweak pointer to ",(0,s.jsx)(n.code,{children:"self"}),". Possibly the developer meant to capture only ",(0,s.jsx)(n.code,{children:"weakSelf"}),"\nto avoid a retain cycle, but made a typo and used ",(0,s.jsx)(n.code,{children:"self"})," as well in the block,\ninstead of ",(0,s.jsx)(n.code,{children:"strongSelf"}),". In this case, this could cause a retain cycle."]}),"\n",(0,s.jsx)(n.h2,{id:"modifies_immutable",children:"MODIFIES_IMMUTABLE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Modifies Immutable" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-impurity",children:"impurity"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This issue type indicates modifications to fields marked as @Immutable. For instance, below function ",(0,s.jsx)(n.code,{children:"mutateArray"})," would be marked as modifying immutable field ",(0,s.jsx)(n.code,{children:"testArray"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  @Immutable int[] testArray = new int[]{0, 1, 2, 4};\n  \n  int[] getTestArray() {\n    return testArray;\n  }                \n          \n  void mutateArray() {\n    int[] array = getTestArray();\n    array[2] = 7;\n  }\n"})}),"\n",(0,s.jsx)(n.h2,{id:"multiple_weakself",children:"MULTIPLE_WEAKSELF"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Multiple WeakSelf Use" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-self-in-block",children:"self-in-block"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["An Objective-C block uses ",(0,s.jsx)(n.code,{children:"weakSelf"})," more than once. This could lead to\nunexpected behaviour. Even if ",(0,s.jsx)(n.code,{children:"weakSelf"})," is not nil in the first use, it could\nbe nil in the following uses since the object that ",(0,s.jsx)(n.code,{children:"weakSelf"})," points to could be\nfreed anytime. One should assign it to a strong pointer first, and then use it\nin the block."]}),"\n",(0,s.jsx)(n.h2,{id:"mutable_local_variable_in_component_file",children:"MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Mutable Local Variable In Component File" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.a,{href:"http://componentkit.org/docs/avoid-local-variables",children:"Doc in ComponentKit page"})}),"\n",(0,s.jsx)(n.h2,{id:"nil_messaging_to_non_pod",children:"NIL_MESSAGING_TO_NON_POD"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Nil Messaging To Non Pod" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#nullptr_dereference",children:"NULLPTR_DEREFERENCE"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"nullptr_dereference",children:"NULLPTR_DEREFERENCE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Nullptr Dereference" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Infer reports null dereference bugs in Java, C, C++, and Objective-C\nwhen it is possible that the null pointer is dereferenced, leading to\na crash."}),"\n",(0,s.jsx)(n.h3,{id:"null-dereference-in-java",children:"Null dereference in Java"}),"\n",(0,s.jsx)(n.p,{children:"Many of Infer's reports of potential Null Pointer Exceptions (NPE) come from code of the form"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  p = foo(); // foo() might return null\n  stuff();\n  p.goo();   // dereferencing p, potential NPE\n"})}),"\n",(0,s.jsx)(n.p,{children:"If you see code of this form, then you have several options."}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsxs)(n.strong,{children:["If you are unsure whether or not ",(0,s.jsx)(n.code,{children:"foo()"})," will return null"]}),", you should\nideally either"]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Change the code to ensure that ",(0,s.jsx)(n.code,{children:"foo()"})," can not return null, or"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Add a check that ",(0,s.jsx)(n.code,{children:"p"})," is not ",(0,s.jsx)(n.code,{children:"null"})," before dereferencing ",(0,s.jsx)(n.code,{children:"p"}),"."]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes, in case (2) it is not obvious what you should do when ",(0,s.jsx)(n.code,{children:"p"}),"\nis ",(0,s.jsx)(n.code,{children:"null"}),". One possibility is to throw an exception, failing early but\nexplicitly. This can be done using ",(0,s.jsx)(n.code,{children:"checkNotNull"})," as in the following\ncode:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"// code idiom for failing early\nimport static com.google.common.base.Pre
1conditions.checkNotNull;\n\n  //... intervening code\n\n  p = checkNotNull(foo()); // foo() might return null\n  stuff();\n  p.goo(); // p cannot be null here\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The call ",(0,s.jsx)(n.code,{children:"checkNotNull(foo())"})," will never return ",(0,s.jsx)(n.code,{children:"null"}),": if ",(0,s.jsx)(n.code,{children:"foo()"}),"\nreturns ",(0,s.jsx)(n.code,{children:"null"})," then it fails early by throwing a Null Pointer\nException."]}),"\n",(0,s.jsxs)(n.p,{children:["Facebook NOTE: ",(0,s.jsx)(n.strong,{children:"If you are absolutely sure that foo() will not be\nnull"}),", then if you land your diff this case will no longer be\nreported after your diff makes it to master."]}),"\n",(0,s.jsx)(n.h3,{id:"null-dereference-in-c",children:"Null dereference in C"}),"\n",(0,s.jsx)(n.p,{children:"Here is an example of an inter-procedural null dereference bug in C:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-c",children:"struct Person {\n  int age;\n  int height;\n  int weight;\n};\nint get_age(struct Person *who) {\n  return who->age;\n}\nint null_pointer_interproc() {\n  struct Person *joe = 0;\n  return get_age(joe);\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"null-dereference-in-objective-c",children:"Null dereference in Objective-C"}),"\n",(0,s.jsxs)(n.p,{children:["In Objective-C, null dereferences are less common than in Java, but they still\nhappen and their cause can be hidden. In general, passing a message to nil does\nnot cause a crash and returns ",(0,s.jsx)(n.code,{children:"nil"}),", but dereferencing a pointer directly does\ncause a crash as well as calling a ",(0,s.jsx)(n.code,{children:"nil"})," block.C"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:"-(void) foo:(void (^)())callback {\n    callback();\n}\n\n-(void) bar {\n    [self foo:nil]; //crash\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Moreover, there are functions from the libraries that do not allow ",(0,s.jsx)(n.code,{children:"nil"})," to be\npassed as argument. Here are some examples:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:'-(void) foo {\n    NSString *str = nil;\n    NSArray *animals = @[@"horse", str, @"dolphin"]; //crash\n}\n\n-(void) bar {\n  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); //can return NULL\n  ...\n  CFRelease(colorSpace); //crashes if called with NULL\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"null_dereference",children:"NULL_DEREFERENCE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Null Dereference" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#nullptr_dereference",children:"NULLPTR_DEREFERENCE"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"optional_empty_access",children:"OPTIONAL_EMPTY_ACCESS"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Optional Empty Access" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Optional Empty Access warnings are reported when we try to retrieve the value of a ",(0,s.jsx)(n.a,{href:"https://github.com/facebook/folly/blob/master/folly/Optional.h",children:(0,s.jsx)(n.code,{children:"folly::Optional"})})," when it is empty (i.e. ",(0,s.jsx)(n.code,{children:"folly::none"}),")."]}),"\n",(0,s.jsxs)(n.p,{children:["In the following example we get a warning as ",(0,s.jsx)(n.code,{children:"int_opt"})," might be ",(0,s.jsx)(n.code,{children:"folly::none"})," and its value is being accessed:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"bool somef(int v);\n\nfolly::Optional<int> mightReturnNone(int v) {\n   if (somef(v)) {\n      return folly::Optional(v);\n   }\n\n   return folly::none;\n}\n\nint value_no_check() {\n  folly::Optional<int> int_opt = mightReturnNone (4);\n  return int_opt.value(); // Optional Empty Access warning\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["We do not get the warning anymore if we add a check whether ",(0,s.jsx)(n.code,{children:"int_opt"})," is not empty:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"int value_check() {\n  folly::Optional<int> int_opt = mightReturnNone (4);\n  if (int_opt.has_value()) {\n     return int_opt.value(); // OK\n  }\n  return -1;\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"In some cases we know that we have a non-empty value and there is no need to have a check. Consider the following example where Infer does not warn:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"bool somef(int v) {return v > 3;};\n\nfolly::Optional<int> mightReturnNone(int v) {\n   if (somef(v)) {\n      return folly::Optional(v);\n   }\n\n   return folly::none;\n}\n\nint value_no_check() {\n  folly::Optional<int> int_opt = mightReturnNone (4); // cannot be folly::none\n  return int_opt.value(); // OK\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"parameter_not_null_checked",children:"PARAMETER_NOT_NULL_CHECKED"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Parameter Not Null Checked" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This error type is reported only in Objective-C. It is similar to Null\ndereference, but Infer hasn't found a whole trace where the error can happen,\nbut only found that a null dereference can happen if you call a method with nil\nas an argument. Therefore it is only a warning. For example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:"  -(int) foo:(A* a) {\n      B *b = [a foo]; // sending a message with receiver nil returns nil\n      return b->x; // dereferencing b, potential NPE if you pass nil as the argument a.\n  }\n"})}),"\n",(0,s.jsx)(n.p,{children:"or when the parameter is a block:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:"   -(void) foo:(void (^)(BOOL))block {\n      block(YES); // calling a nil block will cause a crash.\n   }\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Possible solutions are adding a check for ",(0,s.jsx)(n.code,{children:"nil"}),", or making sure that the method\nis not called with ",(0,s.jsx)(n.code,{children:"nil"}),". When an argument will never be ",(0,s.jsx)(n.code,{children:"nil"}),", you can add the\nannotation ",(0,s.jsx)(n.code,{children:"nonnull"})," to the argument's type, to tell Infer (and the type\nsystem), that the argument won't be ",(0,s.jsx)(n.code,{children:"nil"}),". This will silence the warning."]}),"\n",(0,s.jsx)(n.h2,{id:"pointer_to_const_objc_class",children:"POINTER_TO_CONST_OBJC_CLASS"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Pointer To Const Ob
1jc Class" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["In Objective-C, ",(0,s.jsx)(n.code,{children:"const Class *"})," represents a mutable pointer pointing to an\nObjective-C class where the ivars cannot be changed. More useful is\n",(0,s.jsx)(n.code,{children:"Class *const"})," instead, meaning the destination of the pointer cannot be\nchanged."]}),"\n",(0,s.jsx)(n.h2,{id:"premature_nil_termination_argument",children:"PREMATURE_NIL_TERMINATION_ARGUMENT"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Premature Nil Termination Argument" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This error type is reported in C and Objective-C. In many variadic methods,\n",(0,s.jsx)(n.code,{children:"nil"})," is used to signify the end of the list of input objects. This is similar\nto nil-termination of C strings. If one of the arguments that is not the last\nargument to the method is ",(0,s.jsx)(n.code,{children:"nil"})," as well, Infer reports an error because that may\nlead to unexpected behavior."]}),"\n",(0,s.jsxs)(n.p,{children:["An example of such variadic methods is\n",(0,s.jsx)(n.a,{href:"https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/index.html#//apple_ref/occ/clm/NSArray/arrayWithObjects",children:"arrayWithObjects"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:'  NSArray *foo = [NSArray arrayWithObjects: @"aaa", str, @"bbb", nil];\n'})}),"\n",(0,s.jsxs)(n.p,{children:["In this example, if ",(0,s.jsx)(n.code,{children:"str"})," is ",(0,s.jsx)(n.code,{children:"nil"})," then an array ",(0,s.jsx)(n.code,{children:'@[@"aaa"]'})," of size 1 will be\ncreated, and not an array ",(0,s.jsx)(n.code,{children:'@[@"aaa", str, @"bbb"]'})," of size 3 as expected."]}),"\n",(0,s.jsx)(n.h2,{id:"pulse_uninitialized_value",children:"PULSE_UNINITIALIZED_VALUE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Uninitialized Value" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["See ",(0,s.jsx)(n.a,{href:"#uninitialized_value",children:"UNINITIALIZED_VALUE"}),". Re-implemented using Pulse."]}),"\n",(0,s.jsx)(n.h2,{id:"pure_function",children:"PURE_FUNCTION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Pure Function" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-purity",children:"purity"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This issue type indicates pure functions. For instance, below functions would be marked as pure:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"int local_write_pure(int x, int y) {\n  int k = x + y;\n  k++;\n  return k;\n}\n\n// no change to outside state, the local allocation is ok.\nint local_alloc_pure(ArrayList<Integer> list) {\n  ArrayList<Integer> list_new = new ArrayList<Integer>();\n  for (Integer el : list) {\n    list_new.add(el);\n  }\n  return list_new.size();\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"However, the following ones would not be pure:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"void swap_impure(int[] array, int i, int j) {\n  int tmp = array[i];\n  array[i] = array[j]; // modifying the input array\n  array[j] = tmp;\n}\n\nint a = 0;\nvoid set_impure(int x, int y) {\n  a = x + y; //modifying a global variable\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"quandary_taint_error",children:"QUANDARY_TAINT_ERROR"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Taint Error" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Generic taint error when nothing else fits."}),"\n",(0,s.jsx)(n.h2,{id:"resource_leak",children:"RESOURCE_LEAK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Resource Leak" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Infer reports resource leaks in C, Objective-C and Java. In general, resources\nare entities such as files, sockets, connections, etc, that need to be closed\nafter being used."}),"\n",(0,s.jsx)(n.h3,{id:"resource-leak-in-c",children:"Resource leak in C"}),"\n",(0,s.jsx)(n.p,{children:"This is an example of a resource leak in C code:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-c",children:'-(void) resource_leak_bug {\n    FILE *fp;\n    fp=fopen("c:\\\\test.txt", "r"); // file opened and not closed.\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"resource-leak-in-java",children:"Resource leak in Java"}),"\n",(0,s.jsx)(n.p,{children:"For the remaining of this section, we will c
1onsider examples of resource leaks\nin Java code."}),"\n",(0,s.jsxs)(n.p,{children:["TIP: A common source of bugs is ",(0,s.jsx)("b",{children:"exceptions skipping past close()\nstatements"}),". That is the first thing to look for if INFER reports a potential\nresource leak."]}),"\n",(0,s.jsx)(n.h3,{id:"basics-and-standard-idiom",children:"Basics and Standard Idiom"}),"\n",(0,s.jsxs)(n.p,{children:["Some objects in Java, the ",(0,s.jsx)("i",{children:"resources"}),", are supposed to be closed when you\nstop using them, and failure to close is a ",(0,s.jsx)("i",{children:"resource leak"}),". Resources\ninclude input streams, output streams, readers, writers, sockets, http\nconnections, cursors, and json parsers."]}),"\n",(0,s.jsx)(n.p,{children:"The standard idiom is"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  // Standard idiom\n  Allocate resource\n  try {\n    do some stuff\n  } finally {\n    close resource\n  }\n"})}),"\n",(0,s.jsx)(n.p,{children:"or more for example,"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  //  Standard Idiom\n  public static void foo () throws IOException{\n    FileOutputStream fos = new FileOutputStream(new File("whatever.txt"));\n    try {\n      fos.write(7);\n    } finally {\n      fos.close();\n    }\n  }\n'})}),"\n",(0,s.jsx)(n.p,{children:"and you should use the standard idiom for the most part, when you don't want to\nreturn the resource to the surrounding context."}),"\n",(0,s.jsx)(n.p,{children:"Sometimes people just leave out close(), and that is a bug, but more typically\nexceptional paths are the root of the problem, as in"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  // leak because of exception\n  public static void foo () throws IOException {\n    FileOutputStream fos = new FileOutputStream(new File("whatever.txt"));\n    fos.write(7);   //DOH! What if exception?\n    fos.close();\n  }\n'})}),"\n",(0,s.jsx)(n.p,{children:"where an exception in fos.write will cause execution to skip past the close()\nstatement."}),"\n",(0,s.jsx)(n.h4,{id:"multiple-resources-bugs",children:"Multiple Resources Bugs"}),"\n",(0,s.jsx)(n.p,{children:"We can deal with multiple resources correctly and simply just by nesting the\nstandard idiom."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  // Two Resources nested\n  public static void foo() throws IOException {\n    FileInputStream fis = new FileInputStream(new File("whatever.txt"));\n    try {\n      FileOutputStream fos = new FileOutputStream(new File("everwhat.txt"));\n      try {\n        fos.write(fis.read());\n      } finally {\n        fos.close();\n      }\n    } finally {\n      fis.close();\n    }\n  }\n'})}),"\n",(0,s.jsx)(n.p,{children:"Bugs often occur when using multiple resources in other ways because of\nexceptions in close() methods. For example,"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  // Classic Two Resources Bug\n  public static void foo() throws IOException {\n    FileInputStream fis = null;\n    FileOutputStream fos = null;\n    try {\n      fis = new FileInputStream(new File("whatever.txt"));\n      fos = new FileOutputStream(new File("everwhat.txt"));\n      fos.write(fis.read());\n    } finally {\n      if (fis!=null)  fis.close();\n      if (fos!=null) fos.close();\n    }\n  }\n'})}),"\n",(0,s.jsx)(n.p,{children:"Here, if there is an exception in the call to fis.close() execution will skip\npast fos.close(); a leak."}),"\n",(0,s.jsx)(n.p,{children:"Another way, besides the standard idiom, to deal with this problem is to swallow\nexceptions."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  // Two Resources Fix 1\n  public static void foo() throws IOException {\n    FileInputStream fis = null;\n    FileOutputStream fos = null;\n    try {\n      fis = new FileInputStream(new File("whatever.txt"));\n      fos = new FileOutputStream(new File("everwhat.txt"));\n      fos.write(fis.read());\n    }
1 finally {\n      try {\n        if (fis!=null) fis.close();\n      } catch (Exception e) {};  // Exception swallowing\n      if (fos!=null) fos.close();\n    }\n  }\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You can also swallow the exception on the output stream. Some people prefer not\nto swallow output stream exceptions, and also flush before closing.\n",(0,s.jsx)(n.a,{href:"http://code.google.com/p/guava-libraries/issues/detail?id=1118",children:"http://code.google.com/p/guava-libraries/issues/detail?id=1118"})]}),"\n",(0,s.jsx)(n.p,{children:"Notice that the nested standard idiom does not need the checks for null, which\nare in there in this case to protect against the case when one of the\nallocations throws an exception, in which case one would get a\nNullPointerException."}),"\n",(0,s.jsx)(n.h3,{id:"nested_allocations",children:"Nested_Allocations"}),"\n",(0,s.jsx)(n.p,{children:"When a resource allocation is included as an argument to a constructor, if the\nconstructor fails it can leave an unreachable resource that no one can close."}),"\n",(0,s.jsx)(n.p,{children:"For example gzipOutputStream = new GZIPOutputStream(new FileOutputStream(out));\nis bad in case the outer constructor, GZIPOutputStream, throws an exception. In\nthat case, no one will have a hold of the FileOutputStream and so no one will be\nable to close it."}),"\n",(0,s.jsx)(n.p,{children:"In such a case you need to move the allocation the FileOutputStream out of the\nnested position and name it, so you are able to close if anything goes wrong\nduring execution of the GZIPOutputStream constructor."}),"\n",(0,s.jsx)(n.p,{children:"Here are resources that can throw exceptions i their constructor(s)."}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"ObjectInputStream , ObjectOutputStream, PipedInputStream, PipedOutputStream,\nPipedReader, PipedWriter, JarInputStream, JarOutputStream, GZIPInputStream,\nGZIPOutputStream , ZipFile all throw IOException"}),"\n",(0,s.jsx)(n.li,{children:"PrintStream throws UnsupportedEncodingException"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"The constructors for FileInputStream, FileOutputStream and RandomAccessFile\nthrow FileNotFoundException, but these cases are not problematic in the sense\nthat their arguments are not resources and so they do not cause the nested\nresource leak."}),"\n",(0,s.jsx)(n.h3,{id:"allocation-of-jsonparser-and-cursor-resources",children:"Allocation of JSonParser and Cursor resources"}),"\n",(0,s.jsx)(n.p,{children:'Some resources are created inside libraries instead of by "new".'}),"\n",(0,s.jsx)(n.p,{children:"Cursor is an interface, the actual resources are something like SQLiteCursor.\nSo, every time you call a function that returns a Cursor object, there is an\nallocation."}),"\n",(0,s.jsx)(n.p,{children:"For instance, in the functions from SQLiteDatabase query(\u2026) and rawQuery(\u2026)\nallocate a cursor resource. For SQLiteQueryBuilder, ContentProviderClient,\nContentResolver. MediaStore and DownloadManager it is only query(\u2026) Cursor\nobjects cursor created by these functions need to be closed (i.e.,\ncursor.close())."}),"\n",(0,s.jsx)(n.p,{children:"Similarly, JsonParser is an abstract class, and create a resource in functions\nfrom the class JsonFactory createParser(byte[] data) createParser(byte[] data,\nint offset, int len) createParser(String content) createParser(URL url)\ncreateParser(File f) JsonParser objects js created by these functions need to be\nclosed (jp.close()). On the other hand . JasonParsers gotten from\ncreateParser(InputStream in) and createParser(Reader r) give you JsonParsers\nthat don\u2019t need to be closed. This is because they receive the resource from\nsomewhere that will maintain the responsibility to close it."}),"\n",(0,s.jsx)(n.h3,{id:"escaping-resources-and-exceptions",children:"Escaping resources and exceptions"}),"\n",(0,s.jsx)(n.p,{children:"Sometimes you want to return a resource to the outside, in which case you should\nnot close it, but you still need to be careful of exceptions in case control\nskips past the return leaving no one to close. Here is a simple example of a\npositive use of escaping resources."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  // An escaping resource, shouldn't close\n  public BugReportAttachment createAttachment(File reportDirectory, String fileName)\n      throws FileNotFoundException {\n    File file = new File(reportDirectory, fileName);\n    OutputStream stream = new FileOutputStream(file);\n    return new BugReportAttachment(Uri.fromFile(file), stream);\n  }\n"})}),"\n",(0,s.jsxs)(n.p,{children:["In this case it is intended that an object that wraps ",(0,s.jsx)(n.code,{children:"stream"})," is passed to the\ncaller of ",(0,s.jsx)(n.code,{children:"createAttachment"}),". You should certainly not close stream here,\nbecause it is being passed to the outside."]}),"\n",(0,s.jsx)(n.p,{children:"But for escaping resources like this you still need to be careful of exceptions.\nFor example, in"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  // An escaping resource, and a leak\n  public BugReportAttachment createAttachment(File reportDirectory, String fileName)\n      throws FileNotFoundException {\n    File file = new File(reportDirectory, fileName);\n    OutputStream stream = new FileOutputStream(file);\n    stream.write(7);\n    return new BugReportAttachment(Uri.fromFile(file), stream);\n  }\n"})}),"\n",(0,s.jsx)(n.p,{children:"if stream.write(7) throws an exception, then no one will have a hold of stream,\nand no one will be able to close it; a leak."}),"\n",(0,s.jsx)(n.h3,{id:"java-7s-try-with-resources",children:"Java 7's try-with-resources"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"(For use with Java 7 only)"})}),"\n",(0,s.jsx)(n.p,{children:"Clearly, accounting for the ramifications of all the exceptional cases is\ncomplicated, and there is a better way in Java 7."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  // Two Resources Fix 2; via try-with-resources\n  public static void foo() throws IOException {\n    try (\n      FileInputStream fis = new FileInputStream(new File("whatever.txt"));\n      FileOutputStream fos = new FileOutputStream(new File("everwhat.txt"))\n    ) {\n      fos.write(fis.read());\n    }\n  }\n'})}),"\n",(0,s.jsx)(n.p,{children:"All the complicated exceptional cases above are (apparently) covered by this\nconstruct, and the result is much simpler."}),"\n",(0,s.jsx)(n.p,{children:"So, if you are trying to fix a potential leak in code with multiples resources\nyou can go ahead and try to understand whether the potential leak is real. Or,\nif the code is complex and it is hard to figure out, it would be perfectly\nlegitimate to simply convert the code over to try-with-resources if you have\naccess to Java 7, so as to save yourself some brain-cycles. You will also end up\nwith cleaner code."}),"\n",(0,s.jsxs)(n.p,{children:["If try-with-resources is so great you should ",(0,s.jsx)("i",{children:"always"}),' use it. But you\nshouldn\'t\u2026 Try-with-resources gives resources static scoping, and works via a\nstack discipline. Sometimes, you want a resource to persist beyond scope, as in\nthe escaping example above. In an escaping example maybe you could refactor lots\nof code so that try-with-resources applies, and maybe you cannot in a sensible\nway. This just illustrates that, though you might hear people say that\ntry-with-resources "solves" the resource problem, it does not. It is very\nuseful, but you cannot use it blindly when you see a resource-allocation site.']}
1),"\n",(0,s.jsx)(n.h2,{id:"retain_cycle",children:"RETAIN_CYCLE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Retain Cycle" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-biabduction",children:"biabduction"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"A retain cycle is a situation when object A retains object B, and object B\nretains object A at the same time. Here is an example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:"@class Child;\n@interface Parent : NSObject {\n    Child *child; // Instance variables are implicitly __strong\n}\n@end\n@interface Child : NSObject {\n    Parent *parent;\n}\n@end\n"})}),"\n",(0,s.jsx)(n.p,{children:'You can fix a retain cycle in ARC by using __weak variables or weak properties\nfor your "back links", i.e. links to direct or indirect parents in an object\nhierarchy:'}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-objectivec",children:"@class Child;\n@interface Parent : NSObject {\n    Child *child;\n}\n@end\n@interface Child : NSObject {\n    __weak Parent *parent;\n}\n@end\n"})}),"\n",(0,s.jsx)(n.h2,{id:"shell_injection",children:"SHELL_INJECTION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Shell Injection" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Environment variable or file data flowing to shell."}),"\n",(0,s.jsx)(n.h2,{id:"shell_injection_risk",children:"SHELL_INJECTION_RISK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Shell Injection Risk" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Code injection if the caller of the endpoint doesn't sanitize on its end."}),"\n",(0,s.jsx)(n.h2,{id:"sql_injection",children:"SQL_INJECTION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Sql Injection" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted and unescaped data flows to SQL."}),"\n",(0,s.jsx)(n.h2,{id:"sql_injection_risk",children:"SQL_INJECTION_RISK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Sql Injection Risk" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted and unescaped data flows to SQL."}),"\n",(0,s.jsx)(n.h2,{id:"stack_variable_address_escape",children:"STACK_VARIABLE_ADDRESS_ESCAPE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Stack Variable Address Escape" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Reported when an address pointing into the stack of the current\nfunction will escape to its calling context. Such addresses will\nbecome invalid by the time the function actually returns so are\npotentially dangerous."}),"\n",(0,s.jsx)(n.p,{children:"For example, directly returning a pointer to a local variable:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-C",children:'int* foo() {\n   int x = 42;\n   return &x; // <-- warn here that "&x" will escape\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"starvation",children:"STARVATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "UI Thread Starvation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-starvation",children:"starvation"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This error is reported in Java, and specifically on Android. These reports are\ntriggered when a method that runs on the UI thread may block, thus potentially\nleading to an Application Not Responding error."}),"\n",(0,s.jsx)(n.p,{children:"Infer considers a method as running on the UI thread whenever:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["The method, one of its overrides, its class, or an ancestral class, is\nannotated with ",(0,s.jsx)(n.code,{children:"@UiThread"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["The method, or one of its overrides is annotated with ",(0,s.jsx)(n.code,{children:"@OnEvent"}),", ",(0,s.jsx)(n.code,{children:"@OnClick"}),",\netc."]}),"\n",(0,s.jsxs)(n.li,{children:["The method or its callees call a ",(0,s.jsx)(n.code,{children:"Litho.ThreadUtils"})," method such as\n",(0,s.jsx)(n.code,{children:"assertMainThread"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"The issue is reported when a method deemed to run on the UI thread"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Makes a method call which may block."}),"\n",(0,s.jsx)(n.li,{children:"Takes a lock, and another thread takes the same lock, and before releasing it,\nmakes a call that may block."}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"Calls that may block are considered:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Certain I/O calls."}),"\n",(0,s.jsxs)(n.li,{children:["Two way ",(0,s.jsx)(n.code,{children:"Binder.transact"})," calls."]}),"\n",(0,s.jsx)(n.li,{children:"Certain OS calls."}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"Future"})," or ",(0,s.jsx)(n.code,{children:"AsyncTask"})," calls to ",(0,s.jsx)(n.code,{children:"get"})," without timeouts, or with too large\ntimeouts."]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["To suppress starvation reports in a method ",(0,s.jsx)(n.code,{children:"m()"})," use the\n",(0,s.jsx)(n.code,{children:'@SuppressLint("STARVATION")'})," annotation, as follows:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'  import android.annotation.SuppressLint;\n\n  @SuppressLint("STARVATION")\n  public void m() {\n  ...\n  }\n'})}),"\n",(0,s.jsxs)(n.p,{children:["To signal to Infer that a method does not perform any blocking calls, despite\nappearences, you can use the ",(0,s.jsx)(n.code,{children:"@NonBlocking"})," annotation:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"  import 
1com.facebook.infer.annotation.NonBlocking;\n\n  @NonBlocking\n  public void m() {\n  ...\n  }\n"})}),"\n",(0,s.jsxs)(n.p,{children:["This instructs Infer to filter out any potentially blocking calls in ",(0,s.jsx)(n.code,{children:"m()"}),"\n(also, transitively), and thus any other method can expect no starvation reports\ndue to a call to ",(0,s.jsx)(n.code,{children:"m()"}),". You will need to set up your class path appropriately to\ninclude the JAR files in ",(0,s.jsx)(n.code,{children:"infer/annotations"})," for this annotation to work."]}),"\n",(0,s.jsx)(n.h2,{id:"static_initialization_order_fiasco",children:"STATIC_INITIALIZATION_ORDER_FIASCO"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Static Initialization Order Fiasco" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-siof",children:"siof"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This error is reported in C++. It fires when the initialization of a static\nvariable ",(0,s.jsx)(n.code,{children:"A"}),", accesses a static variable ",(0,s.jsx)(n.code,{children:"B"})," from another translation unit\n(usually another ",(0,s.jsx)(n.code,{children:".cpp"})," file). There are no guarantees whether ",(0,s.jsx)(n.code,{children:"B"})," has been\nalready initialized or not at that point."]}),"\n",(0,s.jsxs)(n.p,{children:["For more technical definition and techniques to avoid/remediate, see the\n",(0,s.jsx)(n.a,{href:"https://isocpp.org/wiki/faq/ctors#static-init-order",children:"FAQ"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"strict_mode_violation",children:"STRICT_MODE_VIOLATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Strict Mode Violation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-starvation",children:"starvation"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Android has a feature called\n",(0,s.jsx)(n.a,{href:"https://developer.android.com/reference/android/os/StrictMode",children:"strict mode"}),",\nwhich if enabled, will flag the occasions where the main thread makes a call\nthat results in disk I/O, waiting on a network socket, etc. The analysis\ncatching starvation errors and deadlocks (the ",(0,s.jsx)(n.code,{children:"--starvation"})," analysis) has the\nability to statically detect such violations."]}),"\n",(0,s.jsxs)(n.p,{children:["To suppress this warning, it's enough to annotate the offending method with\n",(0,s.jsx)(n.code,{children:'@SuppressLint("STRICT_MODE_VIOLATION")'}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"strong_delegate_warning",children:"STRONG_DELEGATE_WARNING"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Strong Delegate Warning" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-linters",children:"linters"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"This check warns you when you have a property called delegate or variations\nthereof which is declared strong. The idea is that delegates should generally be\nweak, otherwise this may cause retain cycles."}),"\n",(0,s.jsx)(n.h2,{id:"strong_self_not_checked",children:"STRONG_SELF_NOT_CHECKED"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "StrongSelf Not Checked" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-self-in-block",children:"self-in-block"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["When a block captures ",(0,s.jsx)(n.code,{children:"weakSelf"})," in the following pattern:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"__weak __typeof(self) weakSelf = self;\n  int (^my_block)() = ^() {\n    __strong __typeof(weakSelf) strongSelf = weakSelf;\n    int y = strongSelf->x;\n"})}),"\n",(0,s.jsxs)(n.p,{children:["the variable ",(0,s.jsx)(n.code,{children:"strongSelf"})," should be checked for ",(0,s.jsx)(n.code,{children:"null"})," before being used,\notherwise this could cause a crash because the weak pointer ",(0,s.jsx)(n.code,{children:"weakSelf"})," could be\n",(0,s.jsx)(n.code,{children:"null"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"thread_safety_violation",children:"THREAD_SAFETY_VIOLATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Thread Safety Violation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-racerd",children:"racerd"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This warning indicates a potential data race in Java. The analyser is called\nRacerD and this section gives brief but a mostly complete description of its\nfeatures. See the ",(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-racerd",children:"RacerD page"})," for more in-depth information and\nexamples."]}),"\n",(0,s.jsx)(n.h3,{id:"thread-safety-what-is-a-data-race",children:"Thread-safety: What is a data race"}),"\n",(0,s.jsx)(n.p,{children:"Here a data race is a pair of accesses to the same member field such that:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"at least one is a write, and,"}),"\n",(0,s.jsx)(n.li,{children:"at least one occurs without any lock synchronization, and,"}),"\n",(0,s.jsx)(n.li,{children:"the two accesses occur on threads (if known) which can run in parallel."}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"thread-safety-potential-fixes",children:"Thread-safety: Potential fixes"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Synchronizing the accesses (using the ",(0,s.jsx)(n.code,{children:"synchronized"})," keyword, thread-exclusion\nsuch as atomic objects, ",(0,s.jsx)(n.code,{children:"volatile"})," etc)."]}),"\n",(0,s.jsx)(n.li,{children:"Making an offending method private -- this will exclude it from being checked\nat the top level, though it will be checked if called by a public method which\nmay itself, e.g., hold a lock when calling it."}),"\n",(0,s.jsxs)(n.li,{children:["Putting the two accesses on the same thread, e.g., by using ",(0,s.jsx)(n.code,{children:"@MainThread"})," or\n",(0,s.jsx)(n.code,{children:"@ThreadConfined"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"thread-safety-conditions-checked-before-reporting",children:"Thread-safety: Conditions checked before reporting"}),"\n",(0,s.jsxs)(n.p,{children:["The class and method are not marked ",(0,s.jsx)(n.code,{children:"@ThreadSafe(enableChecks = false)"}),", and,"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["The method is declared ",(0,s.jsx)(n.code,{children:"synchronized"}),", or employs (non-transitively) locking,\nor,"]}),"\n",(0,s.jsxs)(n.li,{children:["The class is not marked ",(0,s.jsx)(n.code,{children:"@NotThreadSafe"}),", and,","\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["The class/method is marked ",(0,s.jsx)(n.code,{children:"@ThreadSafe,"})," or one of the configured synonyms\nin ",(0,s.jsx)(n.code,{children:".inferconfig"}),", or,"]}),"\n",(0,s.jsx)(n.li,{children:"A parent class, or an override method are marked with the above annotations."}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["NB currently RacerD ",(0,s.jsxs)(n.strong,{children:["does not take into account ",(0,s.jsx)(n.code,{children:"@GuardedBy"})]}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"thread-safety-thread-annotations-recognized-by-racerd",children:"Thread-safety: Thread annotations recognized by RacerD"}),"\n",(0,s.jsxs)(n.p,{children:["These class and method annotations imply the method is on the main thread:\n",(0,s.jsx)(n.code,{children:"@MainThread"}),", ",(0,s.jsx)(n.code,{children:"@UiThread"})]}),"\n",(0,s.jsxs)(n.p,{children:["These method annotations imply the method is on the main thread: ",(0,s.jsx)(n.code,{children:"@OnBind"}),",\n",(0,s.jsx)(n.code,{children:"@OnEvent"}),", ",(0,s.jsx)(n.code,{children:"@OnMount"}),", ",(0,s.jsx)(n.code,{children:"@OnUnbind"}),", ",(0,s.jsx)(n.code,{children:"@OnUnmount"})]}),"\n",(0,s.jsx)(n.p,{children:"Both classes of annotations work through the inheritance tree (i.e. if a parent\nclass or method is marked with one of these annotations, so is the child class /\nmethod override)."}),"\n",(0,s.jsxs)(n.p,{children:["In addition to these, RacerD recognizes many lifecycle methods as necessarily\nrunning on the main thread, eg ",(0,s.jsx)(n.code,{children:"Fragment.onCreate"})," etc."]}),"\n",(0,s.jsxs)(n.p,{children:["Finally, the thread status of being on the main thread propagates backwards\nthrough the call graph (ie if ",(0,s.jsx)(n.code,{children:"foo"})," calls ",(0,s.jsx)(n.code,{children:"bar"})," and ",(0,s.jsx)(n.code,{children:"bar"})," is marked ",(0,s.jsx)(n.code,{children:"@UiThtread"}),"\nthen ",(0,s.jsx)(n.code,{children:"foo"})," is automatically considered on the main thread too). Calling\n",(0,s.jsx)(n.code,{children:"assertMainThread"}),", ",(0,s.jsx)(n.code,{children:"assertOnUiThread"}),", ",(0,s.jsx)(n.code,{children:"checkOnMainThread"})," has the same effect."]}),"\n",(0,s.jsxs)(n.p,{children:["NB RacerD currently ",(0,s.jsxs)(n.strong,{children:["does not recognize ",(0,s.jsx)(n.code,{children:"@WorkerThread"}),", ",(0,s.jsx)(n.code,{children:"@BinderThread"})," or\n",(0,s.jsx)(n.code,{children:"@AnyThread"})]}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"thread-safety-other-annotations-and-what-they-do",children:"Thread-safety: Other annotations and what they do"}),"\n",(0,s.jsxs)(n.p,{children:["These annotations can be found at ",(0,s.jsx)(n.code,{children:"com.facebook.infer.annotation.*"}),"."]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"@Functional"})," This is a method annotation indicating the method always returns\nthe same value. When a method ",(0,s.jsx)(n.code,{children:"foo"})," is annotated ",(0,s.jsx)(n.code,{children:"@Functional"}),", RacerD will\nignore any writes of the return value of ",(0,s.jsx)(n.code,{children:"foo"}),". For example, in\n",(0,s.jsx)(n.code,{children:"this.x = foo()"}),", the write to ",(0,s.jsx)(n.code,{children:"this.x"}
1)," is ignored. The reasoning is that if\nthe method returns the same value whenever it's called, any data race on\n",(0,s.jsx)(n.code,{children:"this.x"})," is benign, if that is the only write."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"@ThreadConfined"})," This is a class/method/field annotation which takes a single\nparameter which can be ",(0,s.jsx)(n.code,{children:"UI"}),", ",(0,s.jsx)(n.code,{children:"ANY"})," or a user chosen string. It indicates to\nRacerD a thread identifier for the class/method/field. Thus,\n",(0,s.jsx)(n.code,{children:"@ThreadConfined(UI)"})," is equivalent to ",(0,s.jsx)(n.code,{children:"@UiThread"}),", and ",(0,s.jsx)(n.code,{children:"@ThreadConfined(ANY)"}),"\nis equivalent to not having the annotation at all, for classes and methods.\nWhen this annotation is applied to a field it instructs Infer to assume\n(without checking) that all accesses to that field are made on the same thread\n(and can, therefore, not race by definition). The intention is that RacerD\nuses that to detect exclusion between accesses occurring on the same thread.\nHowever, only the UI thread is supported at this time, and any user provided\nvalue is considered equal to ",(0,s.jsx)(n.code,{children:"UI"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"@VisibleForTesting"})," A method annotation making Infer consider the method as\neffectively ",(0,s.jsx)(n.code,{children:"private"}),". This means it will not be checked for races against\nother non-private methods of the class, but only if called by one."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"@ReturnsOwnership"})," A method annotation indicating that the method returns a\nfreshly owned object. Accesses to the returned value will not be considered\nfor data races, as the object is in-effect unique and not accessible yet from\nother threads. The main utility of this annotation is in interfaces, where\nInfer cannot look up the implementation and decide for itself."]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"thread_safety_violation_nullsafe",children:"THREAD_SAFETY_VIOLATION_NULLSAFE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Thread Safety Violation in ',(0,s.jsx)(n.code,{children:"@Nullsafe"}),' Class" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-racerd",children:"racerd"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["A ",(0,s.jsx)(n.a,{href:"#thread_safety_violation",children:"Thread Safety Violation"})," in a ",(0,s.jsx)(n.code,{children:"@Nullsafe"})," class."]}),"\n",(0,s.jsx)(n.h2,{id:"topl_error",children:"TOPL_ERROR"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Topl Error" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-topl",children:"topl"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"A violation of a Topl property (user-specified)."}),"\n",(0,s.jsx)(n.h2,{id:"uninitialized_value",children:"UNINITIALIZED_VALUE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Uninitialized Value" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-uninit",children:"uninit"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"A value is read before it has been initialized. For example, in C:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-C",children:"struct coordinates {\n  int x;\n  int y;\n};\n\nvoid foo() {\n  struct coordinates c;\n  c.x = 42;\n  c.y++; // uninitialized value c.y!\n\n  int z;\n  if (z == 0) { // uninitialized value z!\n    // something\n  }\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"unreachable_code",children:"UNREACHABLE_CODE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Unreachable Code" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-bufferoverrun",children:"bufferoverrun"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"A program point is unreachable."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_buffer_access",children:"UNTRUSTED_BUFFER_ACCESS"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted Buffer Access" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted data of any kind flowing to buffer."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_deserialization",children:"UNTRUSTED_DESERIALIZATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted Deserialization" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"User-controlled deserialization."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_deserialization_risk",children:"UNTRUSTED_DESERIALIZATION_RISK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted Deserialization Risk" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"User-controlled deserialization"}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_environment_change_risk",children:"UNTRUSTED_ENVIRONMENT_CHANGE_RISK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted Environment Change Risk" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"User-controlled environment mutation."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_file",children:"UNTRUSTED_FILE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted File" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"User-controlled file creation; may be vulnerable to path traversal and more."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_file_risk",children:"UNTRUSTED_FILE_RISK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted File Risk" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"User-controlled file creation; may be vulnerable to path traversal and more."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_heap_allocation",children:"UNTRUSTED_HEAP_ALLOCATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted Heap Allocation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted data of any kind flowing to heap allocation. this can cause crashes or DOS."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_intent_creation",children:"UNTRUSTED_INTENT_CREATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted Intent Creation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Creating an Intent from user-controlled data."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_url_risk",children:"UNTRUSTED_URL_RISK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted Url Risk" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted flag, environment variable, or file data flowing to URL."}),"\n",(0,s.jsx)(n.h2,{id:"untrusted_variable_length_array",children:"UNTRUSTED_VARIABLE_LENGTH_ARRAY"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Untrusted Variable Length Array" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted data of any kind flowing to stack buffer allocation. Trying to allocate a stack buffer that's too large will cause a stack overflow."}),"\n",(0,s.jsx)(n.h2,{id:"user_controlled_sql_risk",children:"USER_CONTROLLED_SQL_RISK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "User Controlled Sql Risk" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-quandary",children:"quandary"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Untrusted data flows to SQL (no injection risk)."}),"\n",(0,s.jsx)(n.h2,{id:"use_after_delete",children:"USE_AFTER_DELETE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Use After Delete" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}
1),"\n",(0,s.jsxs)(n.p,{children:["An address that was invalidated by a call to ",(0,s.jsx)(n.code,{children:"delete"})," in C++ is dereferenced."]}),"\n",(0,s.jsx)(n.h2,{id:"use_after_free",children:"USE_AFTER_FREE"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Use After Free" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["An address that was invalidated by a call to ",(0,s.jsx)(n.code,{children:"free"})," in C is dereferenced."]}),"\n",(0,s.jsx)(n.h2,{id:"use_after_lifetime",children:"USE_AFTER_LIFETIME"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Use After Lifetime" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"The lifetime of an object has ended but that object is being\naccessed. For example, the address of a variable holding a C++ object\nis accessed after the variable has gone out of scope:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-C++",children:"void foo() {\n     X* p;\n     { // new scope\n       X x = X();\n       p = &x;\n     } // x has gone out of scope\n     p->method(); // ERROR: you should not access *p after x has gone out of scope\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"vector_invalidation",children:"VECTOR_INVALIDATION"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Vector Invalidation" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-pulse",children:"pulse"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["An address pointing into a C++ ",(0,s.jsx)(n.code,{children:"std::vector"})," might have become\ninvalid. This can happen when an address is taken into a vector, then\nthe vector is mutated in a way that might invalidate the address, for\nexample by adding elements to the vector, which might trigger a\nre-allocation of the entire vector contents (thereby invalidating the\npointers into the previous location of the contents)."]}),"\n",(0,s.jsx)(n.p,{children:"For example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-C++",children:'void deref_vector_element_after_push_back_bad(std::vector<int>& vec) {\n  int* elt = &vec[1];\n  int* y = elt;\n  vec.push_back(42); // if the array backing the vector was full already, this\n                     // will re-allocate it and copy the previous contents\n                     // into the new array, then delete the previous array\n  std::cout << *y << "\\n"; // bad: y might be invalid\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"weak_self_in_no_escape_block",children:"WEAK_SELF_IN_NO_ESCAPE_BLOCK"}),"\n",(0,s.jsxs)(n.p,{children:['Reported as "Weak Self In No Escape Block" by ',(0,s.jsx)(n.a,{href:"/docs/1.1.0/checker-self-in-block",children:"self-in-block"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["In many methods that take a block as an argument, the block position is\nannotated with NS_NOESCAPE to mark that the block passed to this method won't be\nleaving the current scope. In those cases, there is no need to use ",(0,s.jsx)(n.code,{children:"weakSelf"})," to\navoid the block to capture ",(0,s.jsx)(n.code,{children:"self"}),". This issue type flags this case."]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},8453(e,n,i){i.d(n,{R:()=>t,x:()=>l});var r=i(6540);const s={},a=r.createContext(s);function t(e){const n=r.useContext(a);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:t(e.components),r.createElement(a.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.