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

RacerD: reports fault issues with openjdk17 #1868

Open
DaLiangg opened this issue Oct 11, 2024 · 0 comments
Open

RacerD: reports fault issues with openjdk17 #1868

DaLiangg opened this issue Oct 11, 2024 · 0 comments

Comments

@DaLiangg
Copy link

Fault issues are founded with openjdk 17, which are not reported with openjdk 8,any suggestions please?

[infer version]
Infer version v1.2.0
[operating system and version]
openEuler release 24.03
[command]
infer run --racerd -- javac Example.java
[Output]
Capturing in javac mode...
Found 1 source file to analyze in /home/xdl/infer-out
4/4 [################################################################################] 100%
Example.java:12: warning: Thread Safety Violation
Read/Write race. Non-private method Example.getIndexSet(...) reads without synchronization from container this.map via call to Map.get(...), which races with the write in method Example.setIndexSet(...).
Reporting because the current class is annotated @ThreadSafe, so we assume that this method can run in parallel with other non-private methods in the class (including itself).
10.
11. public void getIndexSet(String key) {
12. > map.get(key);
13. }
14.
Example.java:16: warning: Thread Safety Violation
Unprotected write. Non-private method Example.setIndexSet(...) mutates container this.map via call to Map.put(...) outside of synchronization.
Reporting because the current class is annotated @ThreadSafe, so we assume that this method can run in parallel with other non-private methods in the class (including itself).
14.
15. public void setIndexSet(String key, Integer value){
16. > map.put(key, value);
17. }
18.
Found 2 issues
Issue Type(ISSUED_TYPE_ID): #
Thread Safety Violation(THREAD_SAFETY_VIOLATION): 2

[Example.java]
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

@threadsafe
public class Example {
private Map<String, Integer> map = new ConcurrentHashMap<>();
{
map.put("key", 1);
}

public void getIndexSet(String key) {
map.get(key);
}

public void setIndexSet(String key, Integer value){
map.put(key, value);
}

}

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