Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to make infer analyze go deeper into the code? #1887

Open
ChengsongTan opened this issue Mar 6, 2025 · 0 comments
Open

[Question] How to make infer analyze go deeper into the code? #1887

ChengsongTan opened this issue Mar 6, 2025 · 0 comments

Comments

@ChengsongTan
Copy link

ChengsongTan commented Mar 6, 2025

It seems that infer has imposed a limit on how deep they analyze loops/number of steps of code. When I have code with multiple loops each going for many iterations, only the first couple of errors that should be spotted are actually found.

Here's a MWE, if we have the long loop at the beginning with 50 iterations commented, like this:

#include <stdio.h>
#include <stdlib.h>

#define BADFUNC(i) do{int *p = malloc(sizeof(int) * (i + 1)); *p = 1;} while(0)

int main() {
    // for (int i = 0; i < 50; i++) {
    //     BADFUNC(i);
    // }
    
    for (int j = 0; j < 1; j++) {
        BADFUNC(j + 50);
    }
    
    for (int k = 0; k < 1; k++) {
        BADFUNC(k + 80);
    }
    
    for (int m = 0; m < 1; m++) {
        BADFUNC(m + 150);
    }
    
    for (int n = 0; n < 1; n++) {
        BADFUNC(n + 190);
    }
    
    printf("Test finished\n");
    return 0;
}


Then all the BADFUNC sites are identified as having memory safety issues.

Uncommenting the first loop with 50 iterations leads to the rest of BADFUNC errors going unnoticed by Infer.

How can we increase this limit, is there an option for specifying this? Or perhaps I'm using Infer in an incorrect way?

Best,
Chengsong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant