infer icon indicating copy to clipboard operation
infer copied to clipboard

Run all checkers

Open lwli11 opened this issue 8 months ago • 8 comments

Is there a way to run all the checkers listed, instead of having to specify each one? Or a command to run all non-experimental checkers?

Thanks!

lwli11 avatar Jun 16 '25 16:06 lwli11

Hi @lwli11! According to infer --help:

--enable-issue-type +issue_type
          Show reports coming from this type of issue. By default, all issue
          types are enabled except the ones listed in --disable-issue-type.
          Note that enabling issue types does not make the corresponding
          checker run; see individual checker options to turn them on or off.
          See also infer-report(1).

Let us know if you have concrete examples where it does not work as expected.

davidpichardie avatar Jun 17 '25 06:06 davidpichardie

Hi @davidpichardie,

First, the documentation on issues to check for is very helpful and makes infer one of the better documented analysis tools. I appreciate knowing what bugs infer targets.

Maybe I'm misunderstanding how to enable all checkers? For example, buffer overruns are enabled by default, but analyzing the following code:

int main(){
        return 1;
}
int arr(){
        int a[3];
        a[5] = 42;
        return 0;
}
infer run -- g++ array.cpp
Capturing in make/cc mode...
Found 1 source file to analyze in infer-out
1/1 [################################################################################] 100% 40.195ms

  No issues found
infer run --bufferoverrun  -- g++ array.cpp
Capturing in make/cc mode...
Found 1 source file to analyze ininfer-out
1/1 [################################################################################] 100% 41.804ms

array.cpp:6: error: Buffer Overrun L1
  Offset: 5 Size: 3.
  4. int arr(){
  5.    int a[3];
  6.    a[5] = 42;
      ^
  7.         return 0;
  8. }


Found 1 issue
            Issue Type(ISSUED_TYPE_ID): #
  Buffer Overrun L1(BUFFER_OVERRUN_L1): 1

Is there a way to run all the default checkers without specifying '--bufferoverrun', etc?

Thanks!

lwli11 avatar Jun 17 '25 13:06 lwli11

I believe --default-checkers does what you want.

ngorogiannis avatar Jun 17 '25 14:06 ngorogiannis

So first, the issue may be that I'm on issue v1.1.0 since the binary for v1.2.0 isn't available: https://github.com/facebook/infer/releases/download/v1.2.0/infer-linux64-v1.2.0.tar.xz

With --default-checkers, I'm still not seeing buffer overruns being checked:

$ infer run --default-checkers -- g++ array.cpp
Capturing in make/cc mode...
Found 1 source file to analyze in /home.local/savve/cn-exercises/tester/infer-out
1/1 [############################################################] 100% 38.94ms

  No issues found

lwli11 avatar Jun 17 '25 14:06 lwli11

--default-checkers is equivalent to a command line that doesn't disable any checkers.

To double check what checkers are enabled by default, look at the top of the log file for a line looking like

[3676281][environment] Active checkers: self-in-block (C/C++/ObjC), parameter-not-null-checked (C/C++/ObjC), static-constructor-stall-checker (C/C++/ObjC), starvation (C/C++/ObjC, Java), pulse (C/C++/ObjC, C#/.Net, Erlang, Hack, Java, Python, Rust, Swift), liveness (C/C++/ObjC), inefficient-keyset-iterator (Java), fragment-retains-view (Java)

On master, buffer overrun is disabled by default.

ngorogiannis avatar Jun 17 '25 14:06 ngorogiannis

Thanks, I see. It seems odd to not enable the bufferoverrun checker but enable the buffer overrun issue to be checked by default.

lwli11 avatar Jun 17 '25 16:06 lwli11

Well, the enabling of checkers and of issues is a two-level process. An enabled-by-default issue on a disabled-by-default checker simply means that when you enable the checker you will get that issue enabled as part of a standard set of issues without having to manually enable each one.

ngorogiannis avatar Jun 17 '25 17:06 ngorogiannis

Why don't add --enable-all?

shargon avatar Jun 24 '25 00:06 shargon