Search Issue Tracker
[Windows] Problem with importing DLLs using DllImport attribute from different threads
Reported by customer:
The function LoadPluginExecutable in Runtime/Misc/Plugins.cpp is not thread safe. This causes a problem if two C# threads are simultaneously calling into DLLs for the first time via functions with the DllImport attribute. The problem is with this code:
library = LoadLibraryW(pluginFileName.c_str());
loadLibraryError = GetLastError();
With the right timing, the 2nd call to SetDllDirectoryW can clear out the DLL path after LoadLibraryW has initiated on another thread, causing it to not have the Plugins sub directory as part of the search path.
We encountered this problem in 2018.2.16f1, but looking at the code for 2019.2 it appears to still exist. We've tested locally with a lock around this code and it addresses the problem.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- [UWP] Solution is created with "Data\Resources" directory which should not exist
- Audio clips on scene end while switching scenes when one scene has Timeline audio playing
- [Hub] Can trigger multiple concurrent Hub installations of the same editor version via Hub link
- [GI - Lightmapper] Invalid texels are not treated the same way in CPU and GPU lightmapper
- Canvas rect returning incorrect size when switching aspect ratios in the Game view