microsoft / referencesource

Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework
https://referencesource.microsoft.com/
MIT License
3.16k stars 1.27k forks source link

Thread-safe in Set_Value #37

Closed kenteltest closed 6 years ago

kenteltest commented 6 years ago

https://github.com/Microsoft/referencesource/blob/7de0d30c7c5ef56ab60fee41fcdb50005d24979a/mscorlib/system/threading/ThreadLocal.cs#L372

If 2 threads enter this part of the code, there may be a situation where ts_finalizationHelper refers to an instance of one LinkedSlotVolatile object, and ts_slotArray refers to another instance

Although I may be wrong

IharBury commented 6 years ago
  1. Both those fields are thread-static
  2. This repo is not the right place to report bugs
kenteltest commented 6 years ago
  1. Ooops. You are right
  2. For the future, where I should do it? Sorry
IharBury commented 6 years ago

Depends on the implementation which is affected by the bug. Try https://github.com/dotnet/core, for example.

kenteltest commented 6 years ago

Thanks