Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace2: fix writing output to file on windows #1323

Closed
ldennington opened this issue Jul 10, 2023 · 1 comment
Closed

trace2: fix writing output to file on windows #1323

ldennington opened this issue Jul 10, 2023 · 1 comment
Assignees

Comments

@ldennington
Copy link
Contributor

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.

@ldennington ldennington self-assigned this Jul 10, 2023
@ldennington ldennington changed the title trace2: fix windows file lock issue trace2: fix writing output to file on windows Jul 10, 2023
@ldennington
Copy link
Contributor Author

Closed with #1340

ldennington added a commit that referenced this issue Aug 1, 2023
**Changes since 2.2.2:**

- Fix a GCM/Git Trace2 file locking issue
  - Issue: #1323 
  - PR: #1340
- Remove symlinks to `git-credential-manager-core` exe
  - Issue: #1322
  - PR: #1327 
- Add fallback http uri to `diagnose` command
  - Issue: #1215
  - PR: #1339
- Workaround MSAL tenant issue with silent auth
  - Issue: #1297
  - PR: #1321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant