Skip to content

WSL 3.0.1: binfmt cli handler takes precedence over WSLInterop, breaking Windows executable interop #41739

Closed

Description

Windows Version

Microsoft Windows 10.0.26200

WSL Version

3.0.1.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.18.40.1-microsoft-standard-WSL2

Distro Version

Debian 13 - Though other users have reported the same issue with Ubuntu and Arch as well.

Other Software

Mono

Repro Steps

  • Setup Debian in WSL
  • Install Mono apt install mono-complete
  • Update WSL to 3.0.1
  • Try to run a Windows binary like notepad.exe

Expected Behavior

The binary should run in Windows via WSLInterop.

Actual Behavior

An error message is printed:

run-detectors: unable to find an interpreter for /mnt/c/WINDOWS/system32/notepad.exe

Diagnostic Logs

No response

Workaround/fix

With the help of Copilot I was able to figure out that a registered binfmt_misc handler matching Windows PE executables (MZ) takes precedence over WSLInterop. In my Debian installation this is the cli handler installed by Mono.

Temporary workaround, disable the "cli" handler with:

sudo update-binfmts --disable cli

Permanent workaround, remove the "cli" handler with (thanks joseaporo):

sudo update-binfmts --package mono-runtime --remove cli /usr/bin/cli

Activity

  1. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    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 script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

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

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. DavidZidar commented on Sep 30, 2026

    @DavidZidar
    Author

    I don't see how logs won't be helpful here, I have described the problem.

  3. joseaporo commented on Sep 30, 2026

    @joseaporo

    Same issue here, confirming it is not Debian-specific.

    Environment

    • WSL 3.0.1.0, kernel 6.18.40.1-microsoft-standard-WSL2
    • Ubuntu 24.04, systemd enabled
    • mono-runtime 6.8.0.105+dfsg-3.6ubuntu2 (pulls in binfmt-support 2.2.2-7, which registers the cli handler on magic MZ)

    Regression window
    Interop worked on kernel 6.18.33.2 and broke on the first boot after the auto-update to 3.0.1. Mono and binfmt-support were installed months earlier and unchanged.

    Likely cause: #40621 ("protect binfmt_misc from cross-distro wipe at shutdown"). It first shipped in prerelease 2.9.3; comparing tags shows it is in 3.0.1 but not in 2.7.14, so stable users are seeing it for the first time.

    Boot journal comparison on the same machine:

    • Every boot before the update logged this from init, after systemd-binfmt ran:
      sh: 1: cannot create /proc/sys/fs/binfmt_misc/WSLInterop: Permission denied
    • Every boot after the update no longer shows that line, and instead shows:
      systemd-binfmt: Failed to flush binfmt_misc rules, ignoring: Read-only file system

    So the old flow appears to have been: systemd flushed the registry, then WSLInterop was registered again last and won. With /status now read-only, the flush fails, WSLInterop is registered early, and binfmt-support.service (ExecStart=update-binfmts --enable) registers cli after it. The most recently registered matching entry wins, so cli intercepts every PE file.

    Workaround notes

    • sudo update-binfmts --disable cli works but does not survive a restart; binfmt-support.service enables cli again on the next boot.
    • Lasting workaround: sudo update-binfmts --package mono-runtime --remove cli /usr/bin/cli (what the mono-runtime prerm runs on uninstall). A mono-runtime upgrade can register it again.

    Any distro with binfmt-support plus a package that registers an MZ handler (mono, wine) is likely affected. WSLInterop should probably keep precedence over distro-registered MZ handlers now that the flush no longer happens.

  4. DavidZidar commented on Sep 30, 2026

    @DavidZidar
    Author

    Nice analysis, thanks! I can confirm that my workaround did not survive a restart and have updated the issue description.

  5. OneBlue commented on Sep 30, 2026

    @OneBlue
    Collaborator

    /logs

  6. microsoft-github-policy-service commented on Sep 30, 2026

    @microsoft-github-policy-service
    Contributor

    Hello! Could you please provide more logs to help us better diagnose your issue?

    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 script will output the path of the log file once done.

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

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body.

    Thank you!

  7. joseaporo commented on Sep 30, 2026

    @joseaporo

    /emailed-logs

  8. julianxhokaxhiu commented on Sep 30, 2026

    @julianxhokaxhiu

    Same issue here on Arch

    ❯ systemctl status systemd-binfmt.service
    × systemd-binfmt.service - Set Up Additional Binary Formats
         Loaded: loaded (/usr/lib/systemd/system/systemd-binfmt.service; static)
         Active: failed (Result: exit-code) since Wed 2026-09-30 22:59:01 CEST; 3s ago
     Invocation: d122c0f34f70473997f796388570412f
           Docs: man:systemd-binfmt.service(8)
                 man:binfmt.d(5)
                 https://docs.kernel.org/admin-guide/binfmt-misc.html
                 https://systemd.io/API_FILE_SYSTEMS
        Process: 1149 ExecStart=/usr/lib/systemd/systemd-binfmt (code=exited, status=1/FAILURE)
       Main PID: 1149 (code=exited, status=1/FAILURE)
       Mem peak: 4.4M
            CPU: 7ms
    
    Sep 30 22:59:01 PC-FISSO systemd[1]: Starting Set Up Additional Binary Formats...
    Sep 30 22:59:01 PC-FISSO systemd-binfmt[1149]: Failed to flush binfmt_misc rules, ignoring: Read-only file system
    Sep 30 22:59:01 PC-FISSO systemd[1]: systemd-binfmt.service: Main process exited, code=exited, status=1/FAILURE
    Sep 30 22:59:01 PC-FISSO systemd[1]: systemd-binfmt.service: Failed with result 'exit-code'.
    Sep 30 22:59:01 PC-FISSO systemd[1]: Failed to start Set Up Additional Binary Formats.
    

    WSL info

    ❯ wsl --version
    Versione WSL: 3.0.1.0
    Versione kernel: 6.18.40.1-1
    Versione WSLg: 1.0.79
    Versione MSRDC: 1.2.7214
    Versione Direct3D: 1.611.1-81528511
    Versione DXCore: 10.0.26100.1-240331-1435.ge-release
    Versione di Windows: 10.0.26300.9550
    
  9. changed the title [-]WSL 3.0.1: Debian binfmt cli handler takes precedence over WSLInterop, breaking Windows executable interop[/-] [+]WSL 3.0.1: binfmt cli handler takes precedence over WSLInterop, breaking Windows executable interop[/+] on Oct 1, 2026
  10. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    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 script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

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

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  11. DavidZidar commented on Oct 1, 2026

    @DavidZidar
    Author

    Logs have been provided by joseaporo. I just updated the issue to make it clear that is is not Debian specific.

  12. julianxhokaxhiu commented on Oct 5, 2026

    @julianxhokaxhiu

    Just wanted to let you know that I tested the 3.0.2 prebuilt binary (available here https://dev.azure.com/shine-oss/wsl/_build/results?buildId=390175&view=artifacts&pathAsName=false&type=publishedArtifacts ) and I've found something curious.

    While the fix for binfmt works and I can run now binaries like code to open VSCode from WSL, the systemd status still is flagged as degraded.

    Reporting the technical info for you to eventually figure out a solution:

    Arch (WSL)

    ❯ ls /proc/sys/fs/binfmt_misc
    CLR  register  status  WSLInterop
    ❯ cat /proc/sys/fs/binfmt_misc/status
    enabled
    ❯ cat /proc/sys/fs/binfmt_misc/CLR
    enabled
    interpreter /usr/bin/mono
    flags:
    offset 0
    magic 4d5a
    ❯ cat /proc/sys/fs/binfmt_misc/WSLInterop
    enabled
    interpreter /init
    flags: PF
    offset 0
    magic 4d5a
    ❯ systemctl --failed
      UNIT                   LOAD   ACTIVE SUB    DESCRIPTION
    ● systemd-binfmt.service loaded failed failed Set Up Additional Binary Formats
    
    Legend: LOAD   → Reflects whether the unit definition was properly loaded.
            ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
            SUB    → The low-level unit activation state, values depend on unit type.
    
    1 loaded units listed.
    
    ~ on  master
    ❯ systemctl status systemd-binfmt.service
    × systemd-binfmt.service - Set Up Additional Binary Formats
         Loaded: loaded (/usr/lib/systemd/system/systemd-binfmt.service; static)
        Drop-In: /run/systemd/generator/systemd-binfmt.service.d
                 └─override.conf
         Active: failed (Result: exit-code) since Mon 2026-10-05 23:13:23 CEST; 1min 10s ago
     Invocation: 3e86a3c721a74abf8adce2704613004a
           Docs: man:systemd-binfmt.service(8)
                 man:binfmt.d(5)
                 https://docs.kernel.org/admin-guide/binfmt-misc.html
                 https://systemd.io/API_FILE_SYSTEMS
       Main PID: 151 (code=exited, status=1/FAILURE)
       Mem peak: 2.3M
            CPU: 12ms
    
    Oct 05 23:13:23 PC-FISSO systemd[1]: Starting Set Up Additional Binary Formats...
    Oct 05 23:13:23 PC-FISSO systemd-binfmt[151]: Failed to flush binfmt_misc rules, ignoring: Read-only file system
    Oct 05 23:13:23 PC-FISSO systemd[1]: systemd-binfmt.service: Main process exited, code=exited, status=1/FAILURE
    Oct 05 23:13:23 PC-FISSO systemd[1]: systemd-binfmt.service: Failed with result 'exit-code'.
    Oct 05 23:13:23 PC-FISSO systemd[1]: Failed to start Set Up Additional Binary Formats.

    WSL

    ❯ wsl --version
    Versione WSL: 3.0.2.0
    Versione kernel: 6.18.40.1-1
    Versione WSLg: 1.0.79
    Versione MSRDC: 1.2.7391
    Versione Direct3D: 1.611.1-81528511
    Versione DXCore: 10.0.26100.1-240331-1435.ge-release
    Versione di Windows: 10.0.26300.9550
    Versione di MSBuild: 1944
    Commit: 0dc1bc1f
    Tempo di compilazione: 00:19:12 Oct  3 2026

    I wonder if the issue is because once you define the binfmt_misc file-system entry point you mark it also as read-only so anything else inside the container can't override it. Wouldn't be much simpler if you define your own custom unit and you make it dependant on systemd-binfmt.service and you register it forcefully on some well-known paths in /var/lib/systemd for eg. so you can generate it as read-only yet systemd picks it up and runs it as a normal unit? Just suggesting ideas as the solution "works" but is not yet in its optimal shape.

    Hope this helps, thanks a lot nevertheless for working on it!

  13. OneBlue commented on Oct 5, 2026

    @OneBlue
    Collaborator

    Fixed by 3.0.2

    There is a remaining issue causing the binfmt unit to get into a failed state, but let's track that as a separate issue

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

Metadata

Metadata

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