Versions Compared

Key

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

...

... writes that initialize the Helper object and the write to the helper field can be done or perceived out of order. As a result, a thread which invokes getHelper() could see a non-null reference to a helper object, but see the default values for fields of the helper object, rather than the values set in the constructor.

Even if the compiler does not reorder those writes, on a multiprocessor, the processor or the memory system may reorder those writes, as perceived by a thread running on another processor.

Also see guideline rule TSM03-J. Do not publish partially initialized objects.

...

Wiki Markup
*LCK10-EX1:* The noncompliant form of the double-checked locking idiom can be used for 32-bit primitive values (for example, {{int}} or {{float}}) \[[Pugh 2004|AA. Bibliography#Pugh 04]\]. Note that it does not work for {{long}} or {{double}} because unsynchronized reads/writes of 64-bit primitives are not guaranteed to be atomic. (See guidelinerule [VNA05-J. Ensure atomicity when reading and writing 64-bit values].)

...

Search for vulnerabilities resulting from the violation of this guideline rule on the CERT website.

Related Guidelines

...