...
... writes that initialize the
Helper
object and the write to thehelper
field can be done or perceived out of order. As a result, a thread which invokesgetHelper()
could see a non-null reference to ahelper
object, but see the default values for fields of thehelper
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
...