[Java] False negatives for "Double-checked locking is not thread-safe"
- Lenguaje dominante
- CodeQL
- Estrellas
- 10.1k
- Forks
- 2.1k
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 141
Descripción
"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.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.