When implementing os::realpath, we needed to use GetFinalPathNameByHandle to properly resolve symlinks, which requires an actual HANDLE to the file. For the sharing permissions, we set FILE_SHARE_READ, // Just reading this file, allow others to do the same., thinking this correct because we only needed read permissions, and were otherwise willing to share the file.
However, this is incorrect, as we need to share the file with other processes that may be writing or even trying to delete the file. So these sharing permissions should be FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE. Note that we still open the file only for reading with GENERIC_READ.
This causes bugs when Mesos tries to get the realpath of files that may be "busy" elsewhere, such as log files or stderr/stdout files (which are open and being written to).