Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalAssetService using unprotected Dictionary<TKey, TValue> causing threads to enter infinite loop #63

Open
davkean opened this issue Aug 3, 2023 · 0 comments

Comments

@davkean
Copy link

davkean commented Aug 3, 2023

Our Visual Studio performance telemetry has caught an issue where LocalAssetService.HasBeenCheckedToday is entering an infinite loop on the following path. When we caught this issue, it was consuming 6 CPU cores of CPU constantly.

doki-theme-visualstudio.dll!doki_theme_visualstudio.LocalAssetService+<HasAssetChangedAsync>d__.MoveNext
doki-theme-visualstudio.dll!doki_theme_visualstudio.LocalAssetService.IsDifferentFromRemoteAsync
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`[System.Boolean].Start
doki-theme-visualstudio.dll!doki_theme_visualstudio.LocalAssetService+<IsDifferentFromRemoteAsync>d__.MoveNext
doki-theme-visualstudio.dll!doki_theme_visualstudio.LocalAssetService.HasBeenCheckedToday
mscorlib!System.Collections.Generic.Dictionary`[System.__Canon,System.DateTime].FindEntry

This is because LocalAssetService can end up reading and writing to the underlying Dictionary<TKey, TValue> from multiple threads at the same time. This can cause curruption of the internal data structures of the dictionary, causing it to enter infinite loop.

Fix is simple, please replace this dictionary with a ConcurrentDictionary<TKey, TValue>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant