[x] Your operating system and version, for example "Debian 9", "MacOS High Sierra", whether you are using Docker, etc.
[x] Which command you ran, for example infer -- make.
[x] The full output in a paste, for instance a gist.
[x] If possible, a minimal example to reproduce your problem (for instance, some code where
infer reports incorrectly, together with the way you run infer to reproduce the incorrect
report).
I've been experimenting with RacerD with a simple Bank class, that stores Accounts in a Map. In this simple version, it fails to detect data races that might occur in concurrent accesses to the same account. Is this expected behaviour?
@ThreadSafe
public class Bank {
private Map<Integer, Account> accounts;
public class Account {
int balance;
public Account(int balance) {
this.balance = balance;
}
public int balance() {
return this.balance;
}
public void deposit(int quant) {
balance += quant;
}
public boolean withdraw(int quant) {
if (quant > balance)
return false;
balance -= quant;
return true;
}
}
public Bank(int n) {
accounts = new HashMap<>();
for (int i = 0; i < n; i++)
accounts.put(i, new Account(0));
}
public int balance(int acc) {
return this.accounts.get(acc).balance();
}
public void deposit(int acc, int quant) {
this.accounts.get(acc).deposit(quant);
}
public boolean withdraw(int acc, int quant) {
return this.accounts.get(acc).withdraw(quant);
}
}
Version of inferInfer version v1.1.0
Operating system
Fedora Linux 36 (Workstation Edition) x86_64
(Downloaded binaries)
Commandinfer run --racerd-only -- javac Bank.java
Output
Capturing in javac mode...
Found 1 source file to analyze in /home/mane/Proj_Inf/banco_simples/infer-out
1/1 [################################################################################] 100% 57.59ms
No issues found
Please include the following information:
infer --version
.infer -- make
.[x] If possible, a minimal example to reproduce your problem (for instance, some code where infer reports incorrectly, together with the way you run infer to reproduce the incorrect report).
I've been experimenting with RacerD with a simple
Bank
class, that storesAccount
s in a Map. In this simple version, it fails to detect data races that might occur in concurrent accesses to the same account. Is this expected behaviour?Version of infer
Infer version v1.1.0
Operating system Fedora Linux 36 (Workstation Edition) x86_64 (Downloaded binaries)
Command
infer run --racerd-only -- javac Bank.java
Output