Examples of errors detected by the V3054 diagnostic

V3054. Potentially unsafe double-checked locking. Use volatile variable(s) or synchronization primitives to avoid this.


RunUO

V3054 Potentially unsafe double-checked locking. Use volatile variable(s) or synchronization primitives to avoid this. Item.cs 1624


private Packet m_RemovePacket;
....
private object _rpl = new object();
public Packet RemovePacket
{
  get
  {
    if (m_RemovePacket == null)
    {
      lock (_rpl)
      {
        if (m_RemovePacket == null)
        {
          m_RemovePacket = new RemoveItem(this);
          m_RemovePacket.SetStatic();
        }
      }
    }

    return m_RemovePacket;
  }
}


Bugs Found

Checked Projects
381
Collected Errors
13 764