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

Files created with WSL distro to Windows drive are corrupted #11604

Open
1 of 2 tasks
flakfizer opened this issue May 21, 2024 · 13 comments
Open
1 of 2 tasks

Files created with WSL distro to Windows drive are corrupted #11604

flakfizer opened this issue May 21, 2024 · 13 comments

Comments

@flakfizer
Copy link

Windows Version

10.0.22631.3593

WSL Version

2.1.5.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.146.1-2

Distro Version

Ubuntu 23.10

Other Software

$ which git
/usr/bin/git

$ git --version
git version 2.40.1

Repro Steps

git clone of a new repo is failing when cloning into a directory outside of the WSL VM using the WSL distro's git binary. The initially created .git dir HEAD and config files appear to be corrupted as seen from within WSL, but not Windows.

(I've anonymized my project and repo names)

$ wslpath -w $(pwd)
C:\dev\proj\myproj

$ git config --list --show-origin
<shows ~/.gitconfig as only config file with expected contents>

$ git clone https://
Cloning into 'MyProj'
fatal: unknown error occurred while reading the configuration files

$ cd MyProj/.git
$ ls -li
ls: cannot access 'config': No such file or directory
ls: cannot access 'HEAD': No such file or directory
total 0
-????????? ? ? ? ? ? HEAD
-????????? ? ? ? ? ? config

$ cat config
cat: config: No such file or directory

$ cat HEAD
cat: HEAD: No file or directory

These files appear to created without issue as accessed directly from Windows:

PS> cd C:\dev\proj\myproj\MyProj.git
PS > ls

Directory: C:\dev\proj\myproj\MyProj\.git

Mode LastWriteTime Length Name


-a---- 5/21/2024 12:35 PM 26 config
-a---- 5/21/2024 12:35 PM 23 HEAD

(expected)

PS > Get-Content config
[core]
ignorecase = true

(expected)

PS > Get-Content HEAD
ref: refs/heads/master

(expected)

strace of the clone shows the newfstatat of config and HEAD failing (not surprisingly, given the above), which is the cause of the clone failure:
$ strace -o clone.strace git clone https://
Cloning into 'MyProj'
fatal: unknown error occurred while reading the configuration files

$ tail -n15 clone.strace
openat(AT_FDCWD, "MyProj", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(3, "", {st_mode=S_IFDIR|0777, st_size=4096, ...}, AT_EMPTY_PATH) = 0
getdents64(3, 0x561125a099a0 /* 3 entries /, 32768) = 72
newfstatat(AT_FDCWD, "MyProj/.git", {st_mode=S_IFDIR|0777, st_size=4096, ...}, AT_SYMLINK_NOFOLLOW) = 0
openat(AT_FDCWD, "MyProj/.git", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4
newfstatat(4, "", {st_mode=S_IFDIR|0777, st_size=4096, ...}, AT_EMPTY_PATH) = 0
getdents64(4, 0x561125a119e0 /
4 entries /, 32768) = 104
newfstatat(AT_FDCWD, "MyProj/.git/config", 0x7ffcef0cff30, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "MyProj/.git/HEAD", 0x7ffcef0cff30, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
getdents64(4, 0x561125a119e0 /
0 entries */, 32768) = 0
close(4) = 0
rmdir("MyProj/.git") = -1 ENOTEMPTY (Directory not empty)
close(3) = 0
exit_group(128) = ?
+++ exited with 128 +++

Other notes:

  • I've be able to reproduce with the "Ubuntu" and "Ubuntu 24.10" WSL distros.
  • I've reproduced this behavior when cloning several other repos.

Expected Behavior

A successfully cloned git repo with .git/{HEAD,config} files accessible via their Windows drive or through WSL.

Actual Behavior

(see repro steps)

Diagnostic Logs

(see repo steps)

Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The scipt will output the path of the log file once done.

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@flakfizer
Copy link
Author

Adding logs from collect-wsl-logs.ps1:

WslLogs-2024-05-21_13-03-20.zip

Copy link

The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.

Diagnostic information
Detected appx version: 2.1.5.0
Found no WSL traces in the logs

@flakfizer
Copy link
Author

I did reproduce the issue when generating the attached logs.

@flakfizer flakfizer changed the title "git clone" within WSL to Windows drive fails due to corrupted HEAD and config files Files created with WSL distro to Windows drive are corrupted May 21, 2024
@flakfizer
Copy link
Author

I just hit the same issue with a plain text file created via vim in my WSL distro, but to another location on the Windows C:\ drive. So the issue is not git-specific. I updated the issue title accordingly.

Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The scipt will output the path of the log file once done.

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@flakfizer
Copy link
Author

Reviewing the /mnt/c mount:

$ mount | grep 'C:\'
C:\ on /mnt/c type 9p (rw,noatime,dirsync,aname=drvfs;path=C:;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=5,wfd=5)

@OneBlue
Copy link
Collaborator

OneBlue commented May 28, 2024

Thank you @flakfizer.

I wonder if the issue comes from the windows filesystem here. Can you share the output of chkdsk ?

Also can you share the full strace of the command that seems to crate the corrupted file ?

@flakfizer
Copy link
Author

flakfizer commented May 29, 2024

chkdsk reports no issues with the volume when run after repo-ing.
("Windows has scanned the file system and found no problems.
No further action is required."). Output is here: chkdsk.out.txt. Note from the initial report that I have no issues accessing the files from Windows and the files have the expected contents.

Redacted full strace output attached here
gitclone.strace.out.redacted.txt
This was created from:
$ strace -o git clone https://[MyRepoUrl]
which produced the error as described above. Note the two "-1 ENOENT" return values near the bottom from the newfstatat calls for .git/{config,HEAD}

.

@EranGon
Copy link

EranGon commented May 30, 2024

If it helps, I also started hitting this issue and I can a persistent repro for it

@atbagga
Copy link

atbagga commented Jun 11, 2024

Duplicate of #11619

Refer to related issue which is closed now. #11619 (comment)

The root cause of the error is in the MDE plug-in for WSL. The issue has been fixed inside that plugin version 1.24.605.1.
You can get the plug-in via updates on windows or https://www.catalog.update.microsoft.com/Search.aspx?q=wsl

@krishnacx
Copy link

krishnacx commented Jun 11, 2024

I just hit the same issue with a plain text file created via vim in my WSL distro, but to another location on the Windows C:\ drive. So the issue is not git-specific. I updated the issue title accordingly.

@flakfizer Can you mention the exact steps of repro while creating a text file and the failure message

@flakfizer
Copy link
Author

I'm not able to reproduce reliably. The comment you referred to was in reference to an issue I hit once but haven't seen since.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants