github / github/codeql

[Java] False negatives for "Double-checked locking is not thread-safe"

Ouverte
#4,007 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
false-positive Java
Langage dominant
CodeQL
Étoiles
10.1k
Forks
2.1k
Merge moyen
2 j 15 h
PR mergées (30 j)
141

Description

"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.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.