Search Unity

UserReportingClient not threadsafe

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

  1. Dark_Swordsman

    Dark_Swordsman

    Joined:
    Dec 4, 2018
    Posts:
    27
    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

    Unity Technologies

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