microsoft / microsoft/WSL

Windows-Binary-Interop fails with "Invalid argument" under certain circumstances

Open
#13,354 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug emailed-logs
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Windows Version

Microsoft Windows [Version 10.0.22631.5624]

WSL Version

2.5.10.0

Are you using WSL 1 or WSL 2?
  • WSL 2
  • WSL 1
Kernel Version

6.6.87.2-1

Distro Version

Ubuntu 24.04.2 LTS (Noble Numbat)

Other Software

No response

Repro Steps

Steps to reproduce:

  • Import a new Installation of Ubuntu using wsl --install Ubuntu and walk through OOBE (create a user).
  • After Setup is complete, switch to root using sudo -i.
  • Run /mnt/c/Windows/System32/wsl.exe --version, it should output version info
  • Create /root/.cache directory and switch to it
  • Run /mnt/c/Windows/System32/wsl.exe --version again, it should still work.
  • Modify /etc/wsl.conf (adding interop options): I am still not sure, what exactly causes this, but according to the documentation, the following should have no changing effect (but it will anyway):
[interop]
enabled=true
appendWindowsPath=true
  • Exit the distribution and terminate it (wsl --terminate Ubuntu)
  • Start it again wsl -d Ubuntu and switch to root
  • Try running /mnt/c/Windows/System32/wsl.exe --version in /root, it should still work
  • Switch to /root/.cache and run /mnt/c/Windows/System32/wsl.exe --version again. Now you should receive:
root@FAVF-5CD4468BBT:~/.cache# /mnt/c/Windows/System32/wsl.exe --version
/mnt/c/Windows/System32/wsl.exe: Invalid argument
                                                 root@FAVF-5CD4468BBT:~/.cache#

Note: We sporadically got errors like these about 1,5 years ago (mostly in systemd services) and only now I have a valid way of reproducing them. So the error persists for quite a while in WSL.

Expected Behavior

The expected behaviour is, that no matter where I execute Windows binaries, they work or I receive a meaningful error on why it does not work.

Actual Behavior

The Windows binary just returns with Invalid argument and exits.

Diagnostic Logs

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure through /mnt/c/Windows/System32/wsl.exe --version after enabling [interop] in /etc/wsl.conf, comparing /root with /root/.cache. Trace the Windows-binary interop entry point involved in the Invalid argument result; done means the command works from both directories or reports a meaningful error.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, ubuntu
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.