facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.89k stars 2.01k forks source link

Failed to detect null derreference using global variable in C #1687

Open dgutson opened 1 year ago

dgutson commented 1 year ago

Please include the following information:

This is a spin-off of #1685. Infer version: 1.1.0 OS: WSL 2, Ubuntu 22.04.1, downloaded linux binary Command: infer --pulse-only -F -g --biabduction -- clang b1.c b2.c

b1.c:

int* ptr;

int f()
{
    return *ptr;
}

b2.c:

int f(void);
extern int* ptr;

int main(void)
{
    ptr = 0;
    return f();
}

infer fails to detect the null derreference. However, it does detect it if I pass the null as an argument of f() rather than the global var.