facebook / facebook/infer

False Negative in PULSE_RESOURCE_LEAK Detection

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

Description

Hi, the following code example contains a false negative bug. Infer failed to report a `PULSE_RESOURCE_LEAK` warning at line 10, where an `InputStream` resource is not closed after use. The infer version is v1.2.0.

```java
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Optional;

public class Main {
void foo(boolean b) throws IOException, FileNotFoundException {
Optional stream;
if (b) {
stream = Optional.of(new FileInputStream("file.txt")); // should report a warning at this line
}
}
}
```

**Log**
```bash
infer run -- javac Main.java
Capturing in javac mode...
Found 1 source file to analyze in /infer-out
0/3 [................................................................................] 0% 120ms
⊢ [ 0.1s][17.8M] Main.java: Main.()
⊢ [ 0.1s][17.8M] Main.java: void Main.foo(boolean)
3/3 [################################################################################] 100% 170ms
⊢ [ 0.0s][17.8M] idle
⊢ [ 0.0s][17.8M] idle
⊢ [ 0.0s][17.8M] idle

No issues found
```

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.