WSL: gzip from Ubuntu Eoan doesn't execute
-
Your Windows build number: 1903 (18362.295)
-
What you’re doing and what’s happening:
wsl@MSI-GS73:~ $ gzip -bash: /bin/gzip: cannot execute binary file: Exec format error 126|wsl@MSI-GS73:~ $ apt list gzip Listing... Done gzip/eoan,now 1.10-0ubuntu3 amd64 [installed] wsl@MSI-GS73:~ $ -
What’s wrong / what should be happening instead:
gzipfrom Ubuntu Eoan gives the above unexpected error. The same binary behaves perfectly well on a native Linux box (tested on Ubuntu Bionic / Disco and Debian Stretch / Buster). -
Strace of the failing command, if applicable: No strace because the binary doesn’t run at all 😦
-
For WSL launch issues, please collect detailed logs.
See our contributing instructions for assistance.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 11
- Comments: 64 (5 by maintainers)
use this command may help
Given the Ubuntu/Debian patches to gzip, it may be safest to follow @maxb’s recommendation to downgrade to Disco’s gzip:
https://packages.ubuntu.com/disco/amd64/gzip/downloadsudo dpkg -i ./gzip_1.9-3_amd64.debsudo apt-mark hold gzipWhen this issue has been resolved:
sudo apt-mark unhold gzipI got the same error under Ubuntu 22.04, gzip 1.10, WSL1. Solved by upgrading gzip to a newer version, in my case 1.12.
http://ftp.debian.org/debian/pool/main/g/gzip/sudo dpkg -i ./gzip_1.12-1_amd64.debThe current issue with GZip on Ubuntu is better described in #8219 and it’s cause is different from this thread. It’s caused by the WSL 1 ELF loader. While there might be ways to fix that distro side, it’s quite unpredictable when and which binary will be the next affected by such problem.
Anyone willing to confirm what’s been reported in the referred issue can try the following command to patch the gzip binary and clarify whether that’s accurate or a new issue arose:
echo -en '\x10' | sudo dd of=/usr/bin/gzip count=1 bs=1 conv=notrunc seek=$((0x189))@nsynecs it works well,thanks!! my WSL1 version is Ubuntu 22.04 LTS.
I can confirm that this works! I had the same problem as the people above. With WSL 1 Ubuntu 22.04 installing Visual Studio Code would throw the following error:
After running your magic line it immediately worked:
Hitting this on rocky linux and fixed by
Fixed it for me as well.
We have also released a fixed gzip in Ubuntu. Just run
apt update && apt install gzipon Eoan to get the fix and make gzip work with earlier Windows 10 releases as well.Confirmed better in 19025 WSL 1.
Reported to Ubuntu here.
@nsynecs, thank you, fixed right now. I used this version for WSL Ubuntu 22.04 x86_x64.
@rbalint - Yes, I will see about getting this backported.
Thanks for filing this issue, I identified where this is blowing up in our elf loader and will submit a fix.
The difference here isn’t related to a change in
gzip, but to a change infile. Ubuntu binaries have been built with PIE for a while; but it’s only recently (coreutils 5.33) thatfilehas started identifying them as PIE executables rather than shared objects.@as17501 's solution works for WSL 1, Ubuntu 22.04. eg:
That being said - I’m surprised this bug to a core piece of Ubuntu software (gzip) used in a distribution somehow made it into production. Am I missing something and there’s very little testing of WSL, or is this a separation of concerns issue where “WSL works” from a Microsoft standpoint, but the Ubuntu distribution doesn’t; eg it’s Canonical’s issue. Should we be raising it with Canonical as the issue has been around since 2019. Cheers
Note binaries are built with debug symbols, which are then stripped. Maybe stripping is bad. Also maybe dwz debug symbols are not compatible with our stripping. Possibly binutils regression in eoan.
Things to try:
@rbalint - File is only 97496 bytes, this PT_LOAD header is outside of that range.
Nope. Because WSL2 works.
gzip package version
1.10-4ubuntu4.1was published with a patch that addresses this particular issue.sudo apt update && sudo apt install gzipis enough to install it.I thought the gzip patch fixed my issue on WSL 2, but as it turned out, I was using WSL 1 and didn’t realize it! run
wsl -l -vto be sure.@as17501 in your example you wget
amdbut then dpkgarm@benhillis fixed binutil’s strip and recompiled gzip. The fixed binutils tries to not point the offset past EOF, so we don’t trigger the problem in WSL1 with new binaries. It is funny that only gzip was affected in the archive. Ubuntu 20.04 and later also have the fix already.
Thank you. It seems like it is a temporary solution for:
@maxb - Sure. The issue is that our loader was not correctly handling program headers that would exceed the size of the file itself. The offending program header file size of zero but an offset that was greater than the size of the binary. Hope that helps.
@benhillis could you please backport the fix to non-insider versions?
From upstream:
The interesting thing is they are all PIE (f.e.
/bin/ls), and yet the whole Ubuntu edifice doesn’t fall down. I took a quick look withreadelf(1)and there isn’t anything glaring, but isn’t saying much.Reasonable enough WSL1 work around would be to install your own
/usr/local/bin/gzipI guess, although we can’t know what other executables other thangzipmight be problematic.I can reproduce your issue in latest Windows 10 Pro insider build 18970. Here are some points that I found:
file $(which gzip)command showsELF 64-bit LSB shared object.file $(which gzip)command showsELF 64-bit LSB pie executable.LX: (FFFF800368A7C2C0, FFFF800367A04080) (-bash) LxpElfInfoParse: ElfSizeAdd