github / github/codeql

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

Aberta
#4,007 2 comentários 0 reações 0 responsáveis Ver no GitHub
false-positive Java
Linguagem predominante
CodeQL
Estrelas
10.1k
Forks
2.1k
Merge médio
2d 15h
PRs com merge (30d)
141

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.