### Start Transition Example Source: https://github.com/facebook/infer/blob/main/infer/documentation/checkers/Topl.md Illustrates a common transition that allows the property to start at any point in the program. ```plaintext start -> start: * ``` -------------------------------- ### Start Transition Example Source: https://github.com/facebook/infer/blob/main/website/docs/checker-topl.md Illustrates a common transition where the property can start at any point in the program, not necessarily the beginning of a method. ```infer start -> start: * ``` -------------------------------- ### Setup Development Environment Source: https://github.com/facebook/infer/blob/main/CONTRIBUTING.md Run this command after installing development dependencies to set up your development environment. ```sh make devsetup ``` -------------------------------- ### start Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/IBase/DBWriter/index.html Starts the database writer process. ```APIDOC ## start ### Description Starts the database writer process. ### Method `val` ``` -------------------------------- ### Install Website Dependencies Source: https://github.com/facebook/infer/blob/main/website/README.md Run this command to install the necessary dependencies for the website. On Debian systems, consider using `corepack yarn`. ```bash $ yarn ``` -------------------------------- ### Start Local Development Server Source: https://github.com/facebook/infer/blob/main/website/README.md Starts a local development server that automatically refreshes the browser on most changes. Useful for active development. ```bash $ yarn start ``` -------------------------------- ### OCaml AST Visitor Example Source: https://github.com/facebook/infer/blob/main/facebook-clang-plugins/clang-ocaml/README.md Example of how to define and set up visitors for Decl and Stmt nodes in the Clang AST. This allows custom actions to be performed on AST nodes during traversal. ```ocaml let print_decl _ decl = prerr (Clang_ast_proj.get_decl_kind_string decl) let print_stmt _ stmt = prerr (Clang_ast_proj.get_stmt_kind_string decl) let print_ast decl = Clang_ast_visit.decl_visitor := print_decl; Clang_ast_visit.stmt_visitor := print_stmt; ignore (Clang_ast_v.validate_decl [] decl) ``` -------------------------------- ### Install Infer into PATH (Alternative) Source: https://github.com/facebook/infer/blob/main/INSTALL.md Adds the Infer binary directory to your system's PATH environment variable, allowing you to run Infer commands from any location without needing `sudo` for installation. ```shell export PATH=`pwd`/infer/bin:$PATH ``` -------------------------------- ### Custom Zlib Installation for CamlZip Source: https://github.com/facebook/infer/blob/main/dependencies/camlzip/README.md When Zlib is installed in non-standard directories, specify ZLIB_LIBDIR and ZLIB_INCLUDE paths during the make process. ```makefile make ZLIB_LIBDIR=/opt/lib ZLIB_INCLUDE=/opt/include all ``` -------------------------------- ### Example .inferconfig JSON Source: https://github.com/facebook/infer/blob/main/website/static/man/1.2.0/infer.1.html This is an example of the JSON structure for an .inferconfig file. It shows how to disable C++ analysis and specify files to block from analysis. ```json { "cxx": false, "infer-block-list-files-containing": ["@gen","/\* no infer \*/"] } ``` -------------------------------- ### CFG Start Node Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Absint/AbstractInterpreter/MakeBackwardWTO/argument-1-T/CFG/index.html Retrieves the starting node of the CFG. ```APIDOC ## val start_node ### Description Get the starting node of the CFG. ### Signature `val start_node : t -> Node.t` ``` -------------------------------- ### Download and Install Infer Binary Release Source: https://github.com/facebook/infer/blob/main/website/docs/00-getting-started.md Use this command to download the latest Infer binary release for Linux and install it in /opt. Replace VERSION with the actual release number. ```bash VERSION=0.XX.Y; \ curl -sSL "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux-x86_64-v$VERSION.tar.xz" \ | sudo tar -C /opt -xJ && \ sudo ln -s "/opt/infer-linux-x86_64-v$VERSION/bin/infer" /usr/local/bin/infer ``` -------------------------------- ### OCamldebug Breakpoint Example Source: https://github.com/facebook/infer/blob/main/CONTRIBUTING.md Example of setting a breakpoint in OCamldebug. Remember to use the prefixed module names (e.g., InferModules__M). ```console $ ledit ocamldebug infer/bin/infer.bc.exe (ocd) break @ InferModules__InferAnalyze 100 Breakpoint 1 at 9409684: file backend/InferAnalyze.ml, line 99, characters 18-78 ``` -------------------------------- ### Install Additional Ubuntu Packages Source: https://github.com/facebook/infer/wiki/Running-Infer-in-Docker Install necessary packages, such as Maven, within the Docker container to support your project's build or Infer's requirements. ```bash apt-get install -y maven ``` -------------------------------- ### Start Node Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Absint/LowerHil/MakeAbstractInterpreter/Interpreter/TransferFunctions/CFG/index.html Retrieves the entry node of the CFG. ```APIDOC ## val start_node ### Description Returns the start node of the CFG. ### Signature `val start_node : t -> Node.t` ### Parameters * **cfg** (`t`) - The Control Flow Graph. ### Returns * `Node.t` - The start node. ``` -------------------------------- ### start_node function Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/IR/WeakTopologicalOrder/module-type-PreProcCfg/index.html Retrieves the starting node of a PreProcCfg. ```APIDOC ## start_node ### Description Retrieves the starting node of a PreProcCfg. ### Signature `val start_node : t -> Node.t` ### Parameters * `t` (type `t`): The PreProcCfg to get the start node from. ### Returns The starting node of type `Node.t`. ``` -------------------------------- ### val lexing_positions Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/Textuallib/TextualLexer/Lexbuf/index.html Gets the current lexing positions (start and end) from a lexbuf. ```APIDOC ## val lexing_positions ### Description Gets the current lexing positions (start and end) from a lexbuf. ### Signature `val lexing_positions : [lexbuf](../index.html#type-lexbuf) -> Stdlib.Lexing.position * Stdlib.Lexing.position` ``` -------------------------------- ### ProcLocker.setup Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/Backend/ProcLocker/index.html Initializes the ProcLocker. This should be called once before attempting to acquire any locks. ```APIDOC ## ProcLocker.setup ### Description Initializes the ProcLocker. This should be called once before attempting to acquire any locks. ### Signature `val setup : unit -> unit` ``` -------------------------------- ### CFG Node Accessors Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Absint/AbstractInterpreter/module-type-MakeExceptional/argument-1-T/CFG/index.html Functions to get the start, exit, and exceptional sink nodes of the CFG. ```APIDOC ## val start_node ### Description Get the start node of the CFG. ### Signature `val start_node : t -> Node.t` ``` ```APIDOC ## val exit_node ### Description Get the exit node of the CFG. ### Signature `val exit_node : t -> Node.t` ``` ```APIDOC ## val exn_sink_node ### Description Get the exceptional sink node of the CFG, if it exists. ### Signature `val exn_sink_node : t -> Node.t option` ``` -------------------------------- ### setup_log_file Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/IBase/Logging/index.html Sets up logging to direct output to a log file. This should be called once after the results directory has been established. ```APIDOC ## setup_log_file ### Description Sets up logging to go to the log file. Call this once the results directory has been set up. ### Method val setup_log_file : unit -> unit ``` -------------------------------- ### Node Accessors Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/Absint/ProcCfg/Normal/index.html Functions to get the start node, exit node, and exceptional sink node of the CFG. ```APIDOC ## val start_node ### Description Get the start node of the CFG. ### Signature `val start_node : t -> Node.t` ## val exit_node ### Description Get the exit node of the CFG. ### Signature `val exit_node : t -> Node.t` ## val exn_sink_node ### Description Get the exceptional sink node of the CFG, if it exists. ### Signature `val exn_sink_node : t -> Node.t option` ``` -------------------------------- ### val get_range_of_iterator Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/BO/BufferOverrunDomain/Val/index.html Get a range of an iterator value, for example, if iterator value is `[lb,ub]`, it returns `[0,ub]` ```APIDOC ## val get_range_of_iterator ### Description Get a range of an iterator value. ### Signature `val get_range_of_iterator : t -> t` ``` -------------------------------- ### CFG Module Functions Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/IR/WeakTopologicalOrder/module-type-Make/argument-1-CFG/index.html This section details the functions available for the CFG type, including how to fold successors and get the starting node. ```APIDOC ## Module CFG ### Description Provides functions to interact with the Control Flow Graph (CFG) structure. ### Type `t` Represents the CFG type. ### Function `fold_succs` #### Signature `val fold_succs : t -> (Node.t, Node.t, 'accum) IStdlib.IStd.Container.fold` #### Description Folds over the successors of a given node in the CFG. ### Function `start_node` #### Signature `val start_node : t -> Node.t` #### Description Returns the starting node of the CFG. ``` -------------------------------- ### Checkout and Build Infer (Java) Source: https://github.com/facebook/infer/blob/main/INSTALL.md Clones the Infer repository, navigates into the directory, and builds the Java analyzer. This is a common starting point for using Infer. ```shell git clone https://github.com/facebook/infer.git cd infer ./build-infer.sh java sudo make install ``` -------------------------------- ### Build and analyze a make-based C project with Infer Source: https://github.com/facebook/infer/blob/main/examples/README.md Use this command to build and analyze a sample make-based C project with Infer. ```bash infer -- make ``` -------------------------------- ### WTO.CFG Module Functions Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/UnitTests/WeakTopologicalOrderTests/WTO/CFG/index.html This section details the functions available in the WTO.CFG module, including how to iterate over successors and get the start node of a CFG. ```APIDOC ## fold_succs ### Description Folds over the successors of a given node in the CFG. ### Signature ``` val fold_succs : t -> (Node.t * Node.t * 'accum) IStdlib.IStd.Container.fold ``` ## start_node ### Description Retrieves the starting node of the CFG. ### Signature ``` val start_node : t -> Node.t ``` ``` -------------------------------- ### Get Location Function Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/Absint/ExplicitTrace/MakeTraceElem/index.html Retrieves the starting location of the trace element. This is either the element's own location or the location of the first call site in the trace. ```APIDOC ## val get_loc : t -> IBase.Location.t ### Description Returns the starting location associated with the trace element. If the trace is empty, it returns the element's own location; otherwise, it returns the location of the first call site in the trace. ### Parameters * **t**: The trace element. ### Returns * **IBase.Location.t**: The starting location of the trace. ``` -------------------------------- ### ProcLocker Setup Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Backend/ProcLocker/index.html Initializes the ProcLocker. This should be called once before attempting to lock any process. ```APIDOC ## val setup : unit -> unit ### Description This should be called once before trying to lock Anything. ### Signature `setup()` ``` -------------------------------- ### Convert JavaClassName to string Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/IR/JavaClassName/index.html Use `to_string` to get the fully qualified string representation of a JavaClassName. For example, `to_string (from_string "X.Y.Z")` returns `"X.Y.Z"`. ```ocaml val to_string : t -> string ``` -------------------------------- ### Get the outer class name for inner classes Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/IR/JavaClassName/index.html Use `get_outer_class_name` to retrieve the closest outer class name for nested or inner classes. For example, for `A$B$C`, it returns `A$B`. Returns `None` if the class is outermost. ```ocaml val get_outer_class_name : t -> t option ``` -------------------------------- ### Example AST Comparison Source: https://github.com/facebook/infer/blob/main/infer/tests/codetoanalyze/hack/semdiff/README.md Illustrates the difference in Abstract Syntax Trees (ASTs) between two versions of a Hack file. This helps in identifying specific fields like 'parameter_type' that have changed. ```text AST1: script( script_declarations=[ ... function_declaration( function_declaration_header=function_declaration_header( function_name="greet", function_parameter_list=[ parameter_declaration( parameter_name="$name")]))]) AST2: script( script_declarations=[ ... function_declaration( function_declaration_header=function_declaration_header( function_name="greet", function_parameter_list=[ parameter_declaration( parameter_name="$name", parameter_type=simple_type_specifier( simple_type_specifier="string"))]))]) ``` -------------------------------- ### Copy File by Chunks Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/NS/Iter/index.html Example demonstrating how to copy a file 'a' to 'b' using chunks of a specified size (4096 bytes). ```ocaml Iterator.IO.(chunks_of ~size:4096 "a" |> write_to "b") ``` -------------------------------- ### Expensive Loop-Invariant Call Example Source: https://github.com/facebook/infer/blob/main/infer/documentation/issues/EXPENSIVE_LOOP_INVARIANT_CALL.md This Java code demonstrates a scenario where a function call within a loop is identified as loop-invariant and expensive. The `incr` function is cheap and not hoisted. `foo_linear` is expensive and its call is hoisted. `symbolic_expensive_hoist` shows an expensive call that gets hoisted. ```java int incr(int x) { return x + 1; } // incr will not be hoisted since it is cheap(constant time) void foo_linear(int size) { int x = 10; for (int i = 0; i < size; i++) { incr(x); // constant call, don't hoist } } // call to foo_linear will be hoisted since it is expensive(linear in size). void symbolic_expensive_hoist(int size) { for (int i = 0; i < size; i++) { foo_linear(size); // hoist } } ``` -------------------------------- ### Install macOS Dependencies with Homebrew Source: https://github.com/facebook/infer/blob/main/INSTALL.md Installs common Infer dependencies on macOS using Homebrew. Ensure Homebrew is installed first. ```shell brew install autoconf automake cmake opam pkg-config sqlite gmp mpfr java ``` -------------------------------- ### select Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/IStdlib/IUnix/index.html Monitors multiple file descriptors for readiness. ```APIDOC ## select ### Description Monitors multiple file descriptors for readiness to read, write, or exceptional conditions. This function can block until one or more file descriptors are ready, or until a timeout occurs. ### Parameters - **restart** (bool, optional) - If true, the select operation will restart if interrupted by a signal. - **read** (IStdlib.IStd.Unix.file_descr list) - A list of file descriptors to check for read readiness. - **write** (IStdlib.IStd.Unix.file_descr list) - A list of file descriptors to check for write readiness. - **except** (IStdlib.IStd.Unix.file_descr list) - A list of file descriptors to check for exceptional conditions. - **timeout** ([select_timeout](#type-select_timeout)) - The maximum time to wait for readiness. ### Returns - [Select_fds.t](Select_fds/index.html#type-t) - An object containing the file descriptors that are ready for the specified operations. ``` -------------------------------- ### initialize Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Pulselib/PulseBaseAddressAttributes/module-type-S/index.html Initializes a new state with a given key and value. ```APIDOC ## val initialize : key -> t -> t ### Description Initializes a new state with a given key and value. ### Parameters - **key**: The key to associate with the initial value. - **t**: The initial value for the state. ### Returns A new state initialized with the provided key and value. ``` -------------------------------- ### init Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/IBase/PerfEvent/index.html Initializes the performance event logging system. ```APIDOC ## init ### Description Initializes the performance event logging system. ### Signature `val init : unit -> unit` ``` -------------------------------- ### CFG Start Node Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Absint/TransferFunctions/module-type-SIL/CFG/index.html Retrieves the starting node of the CFG. ```APIDOC ## val start_node ### Description Get the starting node of the CFG. ### Signature `val start_node : t -> Node.t` ### Parameters * **cfg** (`t`) - The CFG. ``` -------------------------------- ### Compile and Test OCaml Clang Frontend Source: https://github.com/facebook/infer/blob/main/facebook-clang-plugins/clang-ocaml/README.md Commands to set up the environment, install dependencies, and compile/test the OCaml frontend for Clang. ```shell export CLANG_PREFIX=/usr/local make -C clang-ocaml depend make -C clang-ocaml test ``` -------------------------------- ### Timer Start Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/NS/Timer/index.html Starts a timer, marking the beginning of a timing interval. ```APIDOC ## val start : t -> unit ### Description Start a timer. ### Parameters - `t`: The timer object to start. ``` -------------------------------- ### Run Infer on Hello.java Source: https://github.com/facebook/infer/blob/main/examples/README.md Use this command to analyze a simple Java file with Infer. ```bash infer -- javac Hello.java ``` -------------------------------- ### Start and Exit Nodes Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/UnitTests/LivenessTests/TestInterpreter/AI_WTO/T/CFG/index.html Retrieves the start and exit nodes of the CFG. ```APIDOC ## Value `start_node` `val start_node : [t](#type-t) -> [Node.t](Node/index.html#type-t)` Returns the start node of the CFG. ``` ```APIDOC ## Value `exit_node` `val exit_node : [t](#type-t) -> [Node.t](Node/index.html#type-t)` Returns the exit node of the CFG. ``` -------------------------------- ### Build and analyze an Android app with Infer Source: https://github.com/facebook/infer/blob/main/examples/README.md Use this command to build and analyze a sample Android application with Infer. Ensure Android SDK 22 and necessary build tools are installed. ```bash infer -- ./gradlew build ``` -------------------------------- ### init Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/Checkers/LithoDomain/index.html Initializes a LithoDomain for a given procedure. ```APIDOC ## val init ### Description Initializes a LithoDomain for a given procedure, considering type environment, parameters, and local access paths. ### Signature `val init : IR.Tenv.t -> IR.Procname.t -> (IR.Pvar.t * IR.Typ.t) list -> LocalAccessPath.t -> t` ``` -------------------------------- ### Start Node Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Absint/ProcCfg/MakeOcamlGraph/argument-1-Base/index.html Retrieves the starting node of the control flow graph. ```APIDOC ## val start_node ### Description Get the starting node of the control flow graph. ### Signature `val start_node : t -> Node.t` ``` -------------------------------- ### RestartScheduler Setup Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Backend/RestartScheduler/index.html Initializes the RestartScheduler. This function takes no arguments and returns unit. ```APIDOC ## val setup : unit -> unit ### Description Initializes the RestartScheduler. ### Parameters None ### Returns unit ``` -------------------------------- ### CFG Start Node Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/Absint/LowerHil/MakeAbstractInterpreter/argument-1-TransferFunctions/CFG/index.html Retrieves the starting node of the Control Flow Graph. ```APIDOC ## val start_node ### Description Get the starting node of the Control Flow Graph. ### Signature `val start_node : t -> Node.t` ``` -------------------------------- ### Spec Type and Get Function Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/Absint/TaintTrace/module-type-Spec/Source/index.html Defines the `spec` type and the `get` function for retrieving taint specifications. ```APIDOC ## `type spec = { source : t; index : int option }` Represents a taint specification, including the source and an optional index. ## `val get : caller_pname:IR.Procname.t -> CallSite.t -> HilExp.t list -> IR.Tenv.t -> spec list` Returns a list of taint specifications if the call site with the given actuals is a taint source, otherwise returns an empty list. This function helps determine if a call site acts as a source of taint. ``` -------------------------------- ### Deploy Website to GitHub Pages Source: https://github.com/facebook/infer/blob/main/website/README.md Builds the website and pushes the static content to the `gh-pages` branch, suitable for hosting on GitHub Pages. Replace `` with your actual username. ```bash $ GIT_USER= USE_SSH=true yarn deploy ``` -------------------------------- ### Topl Property Start Transition Source: https://github.com/facebook/infer/blob/main/website/versioned_docs/version-1.3.0/checker-topl.md Specifies a transition that is always taken, allowing the property to start at any point in the program. ```topl start -> start: * ``` -------------------------------- ### Initialize List Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/NS/List/index.html Create a list of a given size by applying a function to each index. ```APIDOC ## val init ### Description Create a list of a given size by applying a function to each index. ### Signature ``` val init : int -> f:(int -> 'a) -> 'a list ``` ``` -------------------------------- ### Transition Condition Example Source: https://github.com/facebook/infer/blob/main/website/docs/checker-topl.md Provides an example of a transition condition that checks for reachability between two identifiers using the `~~>` operator. ```infer Ident1 ~~> Ident2 ``` -------------------------------- ### Configure ppx_show with Dune Source: https://github.com/facebook/infer/blob/main/dependencies/ppx_show/README.md Use this configuration in your `dune` file to enable `ppx_show` preprocessing and include its runtime library. This is required for deriving `show` instances. ```lisp (executable ... (preprocess (pps ppx_show)) (libraries ppx_show.runtime) ...) ``` -------------------------------- ### init Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/IBase/DB/Results_dir/index.html Initializes the results directory, optionally with debug mode enabled. ```APIDOC ## init ### Description Initializes the results directory. This function can be called with an optional debug flag. ### Signature `val init : ?debug:bool -> SourceFile.t -> unit` ### Parameters - `?debug`: (Optional) A boolean flag to enable debug mode. - `SourceFile.t`: The source file information. ``` -------------------------------- ### initialize Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/Pulselib/PulseBaseAddressAttributes/module-type-S/index.html Initializes an attribute with a given key. ```APIDOC ## initialize ### Description Initializes an attribute with a given key. ### Signature `val initialize : key -> t -> t` ``` -------------------------------- ### Initial Infer Capture with Gradle Source: https://github.com/facebook/infer/blob/main/website/docs/01-infer-workflow.md Run this command on a clean project to capture all compilation commands for subsequent analysis. This step does not perform an expensive analysis. ```bash gradle clean infer capture -- gradle build ``` -------------------------------- ### Infer Analysis Output Example Source: https://github.com/facebook/infer/blob/main/website/docs/00-hello-world.md Example output from Infer showing detected bugs such as NULL_DEREFERENCE and RESOURCE_LEAK in the Android application code. ```text app/src/main/java/infer/inferandroidexample/MainActivity.java:29: error: NULL_DEREFERENCE object s last assigned on line 28 could be null and is dereferenced at line 29 27. setContentView(R.layout.activity_main); 28. String s = getDay(); 29. > int length = s.length(); 30. writeToFile(); 31. } 32. app/src/main/java/infer/inferandroidexample/MainActivity.java:46: error: RESOURCE_LEAK resource of type java.io.FileOutputStream acquired to fis by call to FileOutputStream(...) at line 43 is not released after line 46 44. fis.write(arr); 45. fis.close(); 46. > } catch (IOException e) { 47. //Deal with exception 48. } 49. app/src/main/java/infer/other/MainActivity.java:23: error: NULL_DEREFERENCE object returned by source() could be null and is dereferenced at line 23 21. @Override 22. protected void onCreate(Bundle savedInstanceState) { 23. > source().toString(); 24. } 25. ``` -------------------------------- ### Integer Overflow Example Source: https://github.com/facebook/infer/blob/main/infer/documentation/issues/INTEGER_OVERFLOW.md This example demonstrates a simple integer overflow scenario where adding 3 to INT_MAX triggers an INTEGER_OVERFLOW_L1 report. ```C int n = INT_MAX; int m = n + 3; ``` -------------------------------- ### Build Infer Source: https://github.com/facebook/infer/blob/main/AGENTS.md Commands to build Infer from the repository root. Ensure initial setup steps like `./build-infer.sh` and `make devsetup` are completed. ```bash make -j ``` ```bash make -j BUILD_MODE=dev-noerror ``` ```bash make -j -C infer/src check ``` ```bash make -j -C infer/src byte ``` ```bash make opt ``` ```bash make fmt ``` ```bash make fmt_all ``` -------------------------------- ### C Code Example for Function Pointer Source: https://github.com/facebook/infer/blob/main/infer/man/man1/infer-full.txt Illustrates C code with a function pointer assignment, relevant for modeling with --starvation-c-function-pointer-models. ```c void (*LOCK_M2_INDIRECTLY)(void) = &lock_m2_indirectly; ``` -------------------------------- ### create Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/IBase/Concurrent/module-type-Hashtbl/index.html Creates a new hash table with a specified initial capacity. ```APIDOC ## create ### Description Creates a new hash table with a specified initial capacity. ### Signature ``` val create : int -> 'a t ``` ``` -------------------------------- ### Unprotected Write Example Source: https://github.com/facebook/infer/blob/main/infer/documentation/checkers/RacerD.md This example demonstrates an unprotected write to a class member variable within a method. RacerD flags this as a potential thread safety violation. ```java @ThreadSafe public class Dinner { private int mTemperature; public void makeDinner() { boilWater(); } private void boilWater() { mTemperature = 100; // unprotected write. } } ``` -------------------------------- ### Creation and Initialization Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/IR/Procname/HashSet/index.html Functions for creating new hash sets. ```APIDOC ## Creation and Initialization ### `create` `val create : int -> [t](#type-t)` Creates a new hash set with a specified initial capacity. The integer argument indicates the expected number of elements, which can be used for optimization. ``` ```APIDOC ### `singleton` `val singleton : [elt](#type-elt) -> [t](#type-t)` Creates a new hash set containing a single specified element. ``` -------------------------------- ### (~+) Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Absint/ProcnameDispatcher/Call/index.html Starts a path with a name that satisfies a given predicate function. This allows for more flexible name matching based on custom criteria. ```APIDOC ## val (~+) ### Description Starts a path with a name that satisfies a given predicate function. ### Signature ``` val (~+) : ('context -> string -> bool) -> ('context, 'f, 'f, 'arg_payload) name_matcher ``` ### Type Parameters - `'context`: The type of the context. - `'f`: The type of the result. - `'arg_payload`: The type of the payload associated with arguments. ### Parameters - `predicate`: A function that takes the context and a string (name) and returns a boolean indicating if the name matches. ``` -------------------------------- ### Interval Specific Operations Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/BO/Itv/index.html Operations specific to interval analysis, such as getting the range of an iterator, getting bounds, and performing semantic equality, greater than or equal to, and greater than comparisons. ```APIDOC ## Interval Specific Operations val get_range_of_iterator : t -> t val get_bound : t -> Symb.BoundEnd.t -> Bound.t Absint.AbstractDomain.Types.bottom_lifted val eq_sem : t -> t -> Boolean.t val ge_sem : t -> t -> Boolean.t val gt_sem : t -> t -> Boolean.t ``` -------------------------------- ### Java Deadlock Example Source: https://github.com/facebook/infer/blob/main/website/versioned_docs/version-1.3.0/all-issue-types.md Illustrates a textbook example of a deadlock where two threads acquire locks in reverse order. This can occur even with synchronized collections like Vector. ```java public void lockAThenB() { synchronized(lockA) { synchronized(lockB) { // do something with both resources } } } public void lockBThenA() { synchronized(lockB) { synchronized(lockA) { // do something with both resources } } } ``` ```java public void lockAThenAddToVector() { synchronized(lockA) { vector.add(object); } } public void lockVectorThenA() { synchronized(vector) { synchronized(lockA) { // do something with both resources } } } ``` -------------------------------- ### Expose OCaml List to Python Source: https://github.com/facebook/infer/blob/main/dependencies/pyml/README.md Creates an OCaml module named 'ocaml' and sets an attribute 'example_value' to a Python list of integers. Then, it evaluates a Python string that imports and prints this value. ```ocaml let m = Py.Import.add_module "ocaml" in Py.Module.set m "example_value" (Py.List.of_list_map Py.Int.of_int [1;2;3]); Py.Run.eval ~start:Py.File " from ocaml import example_value print(example_value)" ``` -------------------------------- ### Read File Lines into List Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/NS/Iter/index.html Example demonstrating how to read all lines of a file 'a' into a list using iterator operations. ```ocaml Iterator.IO.lines "a" |> Iterator.to_list ``` -------------------------------- ### Objective-C Nil Block Call Crash Example Source: https://github.com/facebook/infer/blob/main/infer/documentation/issues/NIL_BLOCK_CALL.md This example demonstrates a common scenario where calling a nil block causes a crash. Ensure callbacks are not nil before invocation. ```objectivec -(void) foo:(void (^)())callback { callback(); } -(void) bar { [self foo:nil]; //crash } ``` -------------------------------- ### Set Creation and Basic Operations Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.3.0/infer/IStdlib/PrettyPrintable/module-type-HashSexpPPSet/index.html Functions for creating and manipulating HashSexpPPSet instances. ```APIDOC ## Set Operations ### `empty` - **Description**: Creates an empty set. - **Type**: `t` ### `add` - **Description**: Adds an element to the set. - **Type**: `elt -> t -> t` ### `singleton` - **Description**: Creates a set with a single element. - **Type**: `elt -> t` ### `remove` - **Description**: Removes an element from the set. - **Type**: `elt -> t -> t` ### `union` - **Description**: Computes the union of two sets. - **Type**: `t -> t -> t` ### `inter` - **Description**: Computes the intersection of two sets. - **Type**: `t -> t -> t` ### `disjoint` - **Description**: Checks if two sets are disjoint. - **Type**: `t -> t -> bool` ### `diff` - **Description**: Computes the difference between two sets. - **Type**: `t -> t -> t` ``` -------------------------------- ### name_matcher operators (~-, ~+) Source: https://github.com/facebook/infer/blob/main/website/static/odoc/1.2.0/infer/Absint/ProcnameDispatcher/module-type-Common/index.html Operators for creating name matchers. `~-` starts a path with a specific name, while `~+` starts a path with a name matching a given predicate. ```APIDOC ## val (~-) Starts a path with a name. ### Signature ``` val (~-) : string -> ('context, 'f, 'f, 'arg_payload) name_matcher ``` ## val (~+) Starts a path with a matching name that satisfies the given function. ### Signature ``` val (~+) : ('context -> string -> bool) -> ('context, 'f, 'f, 'arg_payload) name_matcher ``` ```