Search Issue Tracker
Fixed in 2020.1.X
Fixed in 2018.4.X, 2019.3.X
Votes
0
Found in
2018.2.16f1
2019.2.9f1
Issue ID
1192915
Regression
No
[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:
SetDllDirectoryW(pluginFolder.c_str());
library = LoadLibraryW(pluginFileName.c_str());
loadLibraryError = GetLastError();
SetDllDirectoryW(NULL);
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.
Latest issues
- A submenu disappears on MacOS when the MenuItem method argument "isVariableFunction" is set to "false" and priority argument is set to "-1"
- The Sprite Library Editor window has an incorrect order of Sprites when the Sprites are reordered and the order saved
- Tilemap Tiles do not get lit up unless the Light Range is greater than the distance between the position of the Tile before the transformation and the Light Source when the Tile is transformed with Tilemap.SetTransformMatrix method
- The Editor and "Reloading Domain" windows are frozen when entering Play Mode
- Crash when attempting to create a custom FMOD DSP unit
Add comment