bighugemassive3
bighugemassive3
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
Appreciate the help fred 👍
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
Clear the critical state in case InvokeAsync is called within microseconds
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
I'm thinking this might do the trick
ObjectWrapper? value;
lock (this.stateLock)
{
value = Interlocked.Exchange(ref this.currentValue, null);
this.ClearCriticalState();
}
ObjectWrapper? value;
lock (this.stateLock)
{
value = Interlocked.Exchange(ref this.currentValue, null);
this.ClearCriticalState();
}
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
I guess InvokeAsync updated the value after the first ExecuteCore, and then that cleared the value. But because InvokeAsync was called during the first ExecuteCore, the critical state got set so ExecuteCore was called again
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
Looks like InvokeAsync was called in the same 10~ microsecond window as ExecuteCore
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
InvokeAsync called 3 times sequentially, ExecuteCore called twice sequentially
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
Nevermind, just hit it and i actually did get that case you spoke about
8730397 | 19867.92867 ExecuteCore with FramePFX.Utils.RDA.RateLimitedDispatchAction`1+ObjectWrapper[FramePFX.Editing.UI.ITimelineElement]
8730397 | 19868.05789 InvokeAsync
8730397 | 19868.05834 ExecuteCore with FramePFX.Utils.RDA.RateLimitedDispatchAction`1+ObjectWrapper[FramePFX.Editing.UI.ITimelineElement]
8730397 | 19868.05949 InvokeAsync
8730397 | 19868.19200 InvokeAsync
8730397 | 19868.19279 InvokeAsync
8730397 | 19868.19279 ExecuteCore with FramePFX.Utils.RDA.RateLimitedDispatchAction`1+ObjectWrapper[FramePFX.Editing.UI.ITimelineElement]
8730397 | 19868.31126 ExecuteCore with
8730397 | 19867.92867 ExecuteCore with FramePFX.Utils.RDA.RateLimitedDispatchAction`1+ObjectWrapper[FramePFX.Editing.UI.ITimelineElement]
8730397 | 19868.05789 InvokeAsync
8730397 | 19868.05834 ExecuteCore with FramePFX.Utils.RDA.RateLimitedDispatchAction`1+ObjectWrapper[FramePFX.Editing.UI.ITimelineElement]
8730397 | 19868.05949 InvokeAsync
8730397 | 19868.19200 InvokeAsync
8730397 | 19868.19279 InvokeAsync
8730397 | 19868.19279 ExecuteCore with FramePFX.Utils.RDA.RateLimitedDispatchAction`1+ObjectWrapper[FramePFX.Editing.UI.ITimelineElement]
8730397 | 19868.31126 ExecuteCore with
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
Annoyingly I can't hit the break point with some Debug.WriteLine code added
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
Which is why I introduced the critical continue state, which tells the task to keep running since InvokeAsync was invoked very closely around ExecuteCore
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
InvokeAsync could get called just before or just after ExecuteCore is invoked, and even just before and just after it completes
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
It's why I added the lock so that I could at least get a slice of time to sync everything
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
InvokeAsync could get called at any time so not really
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
Based on GetHashCode
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
No description
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
Oh wait they are different instances lol
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
I don't blame you it's horrid
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
All done with the lock taken
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
I don't see how it's possible though, a new task is only started if S_RUNNING is not present, and S_RUNNING is removed from the state when the current task is just about to exit
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
So there could be 2 tasks somehow?
39 replies
CC#
Created by bighugemassive3 on 12/12/2024 in #help
Race condition with Interlocked.Exchange
The breakpoint didn't hit but that that one case did happen
39 replies