Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The semantics of volatile explicitly exclude any guarantee of the atomicity of compound operations that involve read-modify-write sequences such as incrementing a value. See rule VNA02-J. Ensure that compound operations on shared variables are atomic for more information.

Exceptions

VNA05-EX1EX0: If all reads and writes of 64-bit long and double values occur within a synchronized region, the atomicity of the read/write is guaranteed. This requires both that the value is exposed only through synchronized methods in the class, and also that the value is inaccessible from other code (whether directly or indirectly). For more information, see rule VNA02-J. Ensure that compound operations on shared variables are atomic.)

VNA05-EX2EX1: This rule can be ignored for systems that guarantee that 64-bit, long and double values are read and written as atomic operations. Note, however, that such guarantees fail to be portable across systems.

...

The Coverity Prevent Version 5.0 ATOMICITY checker can detect the instances of non-atomic update of a concurrently shared value. The result of the update will be determined by the interleaving of thread execution.

Related

...

Any vulnerabilities resulting from the violation of this rule are listed on the CERT website.

Related Guidelines

MITRE CWE

CWE ID 667, "Improper Locking"

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6e23ffd05312fd62-230bb28d-43a44d88-b8268280-4bba7e37ae291750f65eeff7"><ac:plain-text-body><![CDATA[

[[Goetz 2006

AA. Bibliography#Goetz 06]]

3.1.2. Non-Atomic 64-Bit Operations

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6e8cf0abdd242e54-0db77892-467b4e0d-888b8ac3-974c5f4a4ed018e19705ca23"><ac:plain-text-body><![CDATA[

[[Goetz 2004c

AA. Bibliography#Goetz 04c]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7acd616616470a67-9e8de7be-40354a2f-a98da937-8a006414a1be7e5d9b17f5e4"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

17.7 Non-atomic Treatment of double and long

]]></ac:plain-text-body></ac:structured-macro>

...