Unicorn with delicious cookie
Мы используем куки, чтобы пользоваться сайтом было удобно.
Хорошо
to the top
>
>
>
Примеры ошибок, обнаруженных с...

Примеры ошибок, обнаруженных с помощью диагностики V3054

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;
  }
}

PowerShell

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


internal static class DebugHelper
{
  private static bool logInitialized = false;     // <=
  ....

  [Conditional("LOGENABLE")]
  private static void WriteLogInternal(string message, int indent, int depth)
  {
    if (!logInitialized)
    {
      lock (logLock)
      {
        if (!logInitialized)
        {
          DebugHelper.GenerateLog = File.Exists(logFile);
          logInitialized = true;
        }
      }
    }
  ....
  }
....
}