github / github/codeql

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

未關閉
#4,007 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
false-positive Java
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。