Skip to content

RacerD: reports fault issues with openjdk17 #1868

@DaLiangg

Description

@DaLiangg

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);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions