Search Unity

UserReportingClient not threadsafe

Discussion in 'Unity Cloud Diagnostics' started by Deleted User, Jul 29, 2019.

  1. Deleted User

    Deleted User

    Guest

    Hi, you are using a regular C# list "synchronizedActions" for scheduling actions from coroutines. The way it is implemented is not threadsafe:

    foreach (Action synchronizedAction in this.synchronizedActions)
    {
    this.currentSynchronizedActions.Add(synchronizedAction);
    }

    this.synchronizedActions.Clear();
    foreach (Action synchronizedAction in this.currentSynchronizedActions)
    {
    synchronizedAction();
    }

    The synchronizedActions list could be modified during the iteration and also before the Clear() call.
     
  2. bretth_unity

    bretth_unity

    Joined:
    Dec 1, 2016
    Posts:
    38
    This will be corrected in the next SDK version. Thank you. :)
     
    Deleted User likes this.