How to debug "denied" file system errors on win32?

I have damn time with our build scripts right now: I use Waf to manage our build process and everything works fine except for Windows, where I get intermittent errors during build.

Errors are always basically “denial of access” errors in one form or another, related to temporary files that I created during the build process in order to run some tool and execute it. For example, before starting NSIS to create an executable installer, I must “generate” all the necessary files in the assembly directory and run the command from there. Sometimes everything works as expected, but in other cases I get an error message about one of the files that I copied, for example:

File: failed opening file "Platform\\Win32\\lxml-2.2.1-py2.6-win32.egg

I spent time trying to understand what the problem was, but it is really difficult because the problem is intermittent. The last thing I tried to use procmon to control access to the file system, to try to track what causes an access error: I know that the file should be there, something is open. I am including the corresponding output below because I cannot see what is wrong: Python seems to close the file before NSIS wants to open it, but then NSIS does not work. Can anyone shed some light on this? This problem is not isolated from this situation, but also in other cases when I create subprocesses for working with files that I copied to create directories ...

7:35:15.9704427 PM  python.exe  4968    QueryOpen   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg FAST IO DISALLOWED  
7:35:15.9707497 PM  python.exe  4968    CreateFile  ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
7:35:15.9708634 PM  python.exe  4968    QueryBasicInformationFile   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS CreationTime: 7/25/2009 7:35:11 PM, LastAccessTime: 7/25/2009 7:35:11 PM, LastWriteTime: 7/25/2009 7:35:11 PM, ChangeTime: 7/25/2009 7:35:11 PM, FileAttributes: A
7:35:15.9709271 PM  python.exe  4968    CloseFile   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS 
7:35:15.9785180 PM  python.exe  4968    CreateFile  ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS Desired Access: Write Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
7:35:15.9786119 PM  python.exe  4968    SetBasicInformationFile ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS CreationTime: 1/1/1601 1:00:00 AM, LastAccessTime: 1/1/1601 1:00:00 AM, LastWriteTime: 1/1/1601 1:00:00 AM, ChangeTime: 1/1/1601 1:00:00 AM, FileAttributes: AN
7:35:15.9787155 PM  python.exe  4968    CloseFile   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS 
7:35:15.9789401 PM  python.exe  4968    QueryOpen   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg FAST IO DISALLOWED  
7:35:15.9790309 PM  python.exe  4968    CreateFile  ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
7:35:15.9790700 PM  python.exe  4968    QueryBasicInformationFile   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS CreationTime: 7/25/2009 7:35:11 PM, LastAccessTime: 7/25/2009 7:35:11 PM, LastWriteTime: 7/25/2009 7:35:11 PM, ChangeTime: 7/25/2009 7:35:12 PM, FileAttributes: A
7:35:15.9790952 PM  python.exe  4968    CloseFile   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS 
7:35:15.9792809 PM  python.exe  4968    CreateFile  ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS Desired Access: Write Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
7:35:15.9793270 PM  python.exe  4968    SetBasicInformationFile ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS CreationTime: 1/1/1601 1:00:00 AM, LastAccessTime: 1/1/1601 1:00:00 AM, LastWriteTime: 1/1/1601 1:00:00 AM, ChangeTime: 1/1/1601 1:00:00 AM, FileAttributes: AN
7:35:15.9794041 PM  python.exe  4968    CloseFile   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS 
7:35:16.3508170 PM  makensis.exe    3296    CreateFile  ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SHARING VIOLATION   Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, AllocationSize: n/a
7:35:16.3557763 PM  python.exe  4968    QueryOpen   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg FAST IO DISALLOWED  
7:35:16.3558928 PM  python.exe  4968    CreateFile  ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
7:35:16.3559461 PM  python.exe  4968    QueryNetworkOpenInformationFile ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS CreationTime: 7/25/2009 7:35:11 PM, LastAccessTime: 7/25/2009 7:35:11 PM, LastWriteTime: 7/25/2009 7:35:11 PM, ChangeTime: 7/25/2009 7:35:12 PM, AllocationSize: 1/1/1601 1:00:00 AM, EndOfFile: 1/1/1601 1:00:00 AM, FileAttributes: A
7:35:16.3560121 PM  python.exe  4968    CloseFile   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS 
7:35:16.3562048 PM  python.exe  4968    CreateFile  ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SHARING VIOLATION   Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
7:35:21.9320579 PM  python.exe  3160    CloseFile   ..\Path\To\Build\lxml-2.2.1-py2.6-win32.egg SUCCESS 
+3
1

, . , - (, ).

+3

Source: https://habr.com/ru/post/1713541/