Hello,
There is a clear (easily detectable via code analysis) bug in UnrealBuildTool tool which lead to build fail under some (rather random) circumstances with the following message (for Windows platform, though another platforms may be affected as well):
error MSB3075: The command “<…>\Build\BatchFiles\Build.bat <…> -waitmutex” exited with code 5. Please verify that you have sufficient rights to run this command.
Please find detailed report below:
Build type : Source
Version : 4.16.2-release / Windows / Visual Studio 2015
Detailed description of the issue:
Under some circumstances source build of UE4 (on Windows platform) failed with one or multiple (random number) of the following messages:
error MSB3075: The command “<…>\Build\BatchFiles\Build.bat <…> -waitmutex” exited with code 5. Please verify that you have sufficient rights to run this command.
where <…> - placeholders for parts of message which are specific for particular case (depend on path to project folder, build configuration, etc.)
The build log also contains following related unhandled exception stacktrace per one such message:
UnrealBuildTool Exception: System.IO.IOException: The process cannot access the file '<UE-Source-Build-Folder>\Engine\Intermediate\Build\XmlConfigCache.bin' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share) at UnrealBuildTool.XmlConfigData.Write(FileReference Location) in <UE-Source-Build-Folder>\Engine\Source\Programs\UnrealBuildTool\System\XmlConfigData.cs:line 124 at UnrealBuildTool.XmlConfig.ReadConfigFiles() in <UE-Source-Build-Folder>\Engine\Source\Programs\UnrealBuildTool\System\XmlConfig.cs:line 93 at UnrealBuildTool.UnrealBuildTool.GuardedMain(String[] Arguments) in <UE-Source-Build-Folder>\Engine\Source\Programs\UnrealBuildTool\System\UnrealBuildTool.cs:line 402 at UnrealBuildTool.UnrealBuildTool.Main(String[] Arguments) in <UE-Source-Build-Folder>\Engine\Source\Programs\UnrealBuildTool\System\UnrealBuildTool.cs:line 927
This stacktrace is self-explanatory and provide the key to the root of issue: there is an interprocess race condition inside the UnrealBuildTool implementation, and in particular - creation of build configuration data cache file named XmlConfigCache.bin. During build of Unreal Engine with Visual Studio, the number of simultaneous UnrealBuildTool processes are spawned and there is race condition occur when each of that processes trying to create XmlConfigCache.bin if it is not exist. Depending on timing one or more of that processes may fail. It is also possible that none of them will fail under lucky timing.
IMPORTANT: because one UnrealBuildTool process will always success and will create the XmlConfigCache.bin, the issue arise only during very first (fresh) build. All consecutive builds will just use already existing XmlConfigCache.bin file and issue will not take the place (Clean command doesn’t delete this file). This should be taken into account during reproducing attempts (see below).
While description above is made for Windows platform, it seems that same issue may arise on other platforms if they also utilize parallel build option (had no chance to test).
Repro Steps:
Because it is race condition (and moreover IPC one), it hard to provide guaranteed repro steps, but below are ones which should provide better chances to reproduce the issue with minimal efforts:
- Make fresh UE build from source
- If issue is not arise, delete <UE-Source-Build-Folder>\Engine\Intermediate\Build\XmlConfigCache.bin file
- Run regular build again (not Rebuild !). Because build is already done, and there are nothing to build, it will be just dry-run for the issue (UnrealBuildTool processes will be spawned as required, but no actual compiling/linking task will be performed, so it will be quick)
- Repeat from step 2 until issue arise (though, there are no guarantee; while in my case I got issue almost each attempt)
Instead of making fresh UE build for step 1 above, existing build may be used - just start from step 2.