Skip to content

trace2: fix writing output to file on windows #1323

Closed
@ldennington

Description

@ldennington

Attempting to set Git's Trace2 Performance Target to write to a file on Windows currently results in the below error (and ugly stack trace):

Unhandled Exception: System.IO.IOException: The process cannot access the file 'C:\Users\<username>\_git\trace-clone.txt' 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, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
   at System.IO.File.InternalAppendAllText(String path, String contents, Encoding encoding)
   at System.IO.File.AppendAllText(String path, String contents)
   at GitCredentialManager.Trace2FileWriter.Write(Trace2Message message)
   at GitCredentialManager.Trace2.WriteMessage(Trace2Message message)
   at GitCredentialManager.Trace2.WriteVersion(String gcmVersion, String filePath, Int32 lineNumber, String eventFormatVersion)
   at GitCredentialManager.Trace2.Start(String appPath, String[] args, String filePath, Int32 lineNumber)
   at GitCredentialManager.Program.AppMain(Object o)
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)

It seems that there is a Windows-specific issue with both GCM and Git writing to the same Trace2 file. This issue tracks investigation of whether there is a viable fix for this scenario. If we are able to successfully discover such a fix, a separate issue will be created to track implementation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions