facebook / facebook/infer

FALSE NEGATIVE: NULLPTR_DEREFERENCE misses a null local after a finite loop

Open
#2,100 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
OCaml
Stars
15.7k
Forks
2.1k
Avg merge
19h 36m
Merged PRs (30d)
13

Description

Hi, I found a false negative in Infer 1.3.0 when object remains null throughout the finite loop and is dereferenced.

**Affected checker**

`Infer NULLPTR_DEREFERENCE`

**Minimal reproducer**

```java
class InferNullAfterLoop {
void step() {}

void test() {
Object object = null;
for (int index = 0; index < 10; index++) {
step();
}
object.toString();
}
}
```

**Reproduction command**

```bash
infer --version
infer run --pulse --enable-issue-type NULLPTR_DEREFERENCE -- javac infer-nullptr-fn-after-loop.java
```

**Current behavior**

Infer completes successfully but produces no `NULLPTR_DEREFERENCE` finding. Changing the loop bound from 10 to 2 makes Infer report the dereference.

**Expected behavior**

Infer should report `NULLPTR_DEREFERENCE` at line 9 because object remains null throughout the finite loop and is dereferenced.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.