You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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 containerthis.map
via call toMap.get(...)
, which races with the write in methodExample.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 containerthis.map
via call toMap.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);
}
}
The text was updated successfully, but these errors were encountered: