[Java] False negatives for "Double-checked locking is not thread-safe"
- Vorherrschende Sprache
- CodeQL
- Sterne
- 10.1k
- Forks
- 2.1k
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 141
Beschreibung
"Double-checked locking is not thread-safe" (`java/unsafe-double-checked-locking`) apparently does not detect certain cases where a non-`volatile` field is re-read:
- https://lgtm.com/projects/g/apache/activemq/snapshot/54a1424c42315b1472af52beab47498a6967827f/files/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java?sort=name&dir=ASC&mode=heatmap#L888
- https://lgtm.com/projects/g/apache/hive/snapshot/dbda9b853a8a72ab5055e91e063b1da5431a38e2/files/llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/LlapUmbilicalPolicyProvider.java?sort=name&dir=ASC&mode=heatmap#L31
The Java Memory Model does not provide any guarantees for these cases so the compiler is free to reorder the read for the return value (which could be `null`) in front of the `null` check.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.