You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Windows build number: Microsoft Windows [Version 10.0.18362.592]
WSL version: 1
Linux distro: Arch WSL
Description:
I'm using Arch WSL in WSL 1 and after an update which bumped glibc from 2.30.3 to 2.31.1 the sleep command stopped working throwing out the error: sleep: cannot read realtime clock: Invalid argument
This affects namely as Ansible, as ansible runs sleep commands in multiple modules. In this issue, on the Arch WSL github (yuk7/ArchWSL#108) , some problems with rust packages were also identified.
Downgrading to the previous version solves the issue. Now, I know that Arch WSL is not an official WSL implementation but this may actually happen when Ubuntu, etc, reach the aforementioned version of glibc
Reacted by Silvio Traversaro, dbz2k, Bart Libert, Hao Zhang(张浩), Parker Snell, therealkenc, Christian Pfeiffer, James Lao, Nathan Hoad, Yuyi Wang and 79 more
For WSL 1 users, I recommend you sit tight on Ubuntu 18.04 for now. The patch for issue 4989 will take some time to be backported. Ubuntu 18.04 is an LTS release, short for long-term servicing, and is supported through 2023 so you will continue to get security patches and backports from Canonical in the meantime.
Also this may all technically be a duplicate of #2503
Most def. Apologies I saw this submission and knew it was dupe #2503 earlier in the afternoon, but got pulled away before I could hit the button. Thanks for going down the rabbit hole.
I'll forward-dupe #2503 as a (probably bad precedent) bump. If this is in glibc it'll hit distros in the store soon enough. Presumably eating CLOCK_REALTIME but providing CLOCK_MONOTONIC semantics in the WSL1 driver would be a pretty small change.
I spoke with one of the senior engineers on our foundations team and they do plan to land glibc 2.31, with the problematic change, in Ubuntu Focal 20.04, our next release in April.
This one would be a useful to have backported unless it can be fixed upstream.
Reacted by Silvio Traversaro, Jozsef Lazar, Shengqi Chen, Gabriel de Perthuis and Jerry DeLisle
As therealkenc surmised, the issue is the lack of CLOCK_REALTIME support in WSL1's clock_nanosleep. We have a fix working internally, which will make its way to insiders. We will also look into backporting this to older Windows versions, but I can't make any promises or provide a timeline for this, unfortunately.
Reacted by therealkenc, Hao Zhang(张浩), Silvio Traversaro, Hayden Barnes, Yuyi Wang, Ilya, Andreas Yankopolus, Neurognostic, beta, Po-wei and 2 more
Reacted by Gabriel de Perthuis, Peng Wang, Po-wei, Dakky and Richard Eitz
J (@jiucenglou) If you want to compile some C or C++, them install at least the "build-essential" ubuntu/debian meta package. Save this hint in your knowledge base.
build-essential is sufficient to compile nanosleep.c tiny C code.
it is already fixed in last dev insider preview, but if you want to get it
in semi ann release, maybe you need to wait several month
Escape0707 <[email protected]> 于2020年8月7日周五 下午11:20写道:
# uname -a
Linux [redacted] 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux# wslsys
Release Install Date: 0x5ceea999
Branch: 19h1_release
Build: 18363
Full Build: 18362.1.amd64fre.19h1_release.190318-1202
Uptime: 6d 4h 6m
Linux Release: Ubuntu Focal Fossa (development branch)
Linux Kernel: Linux 4.4.0-18362-Microsoft
Packages Count: 1367
# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libc-bin : Depends: libc6 (< 2.31) but 2.31-0ubuntu5 is installed
libc-dev-bin : Depends: libc6 (< 2.31) but 2.31-0ubuntu5 is installed
libc6-dev : Depends: libc6 (= 2.30-0ubuntu3) but 2.31-0ubuntu5 is installed
locales : Depends: libc-bin (> 2.31) but 2.30-0ubuntu3 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
# apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
libc-bin libc-dev-bin libc6-dev libcrypt-dev
Suggested packages:
glibc-doc
The following NEW packages will be installed:
libcrypt-dev
The following packages will be upgraded:
libc-bin libc-dev-bin libc6-dev
3 upgraded, 1 newly installed, 0 to remove and 131 not upgraded.
2 not fully installed or removed.
Need to get 0 B/3331 kB of archives.
After this operation, 44.0 kB disk space will be freed.
Do you want to continue? [Y/n]
Setting up libc6:amd64 (2.31-0ubuntu5) ...
Checking for services that may need to be restarted...
Checking init scripts...
Nothing to restart.
sleep: cannot read realtime clock: Invalid argument
dpkg: error processing package libc6:amd64 (--configure):
installed libc6:amd64 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
libc6:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
I "fixed" it somehow on my install. Because the error is in the postinstall script of libc6 package, I simply edited /var/lib/dpkg/info/libc6:amd64.postinst and transformed "sleep 1" in "echo sleep 1".
Then I run, as advised, 'apt --fix-broken install' and it managed to fix the dependencies. I removed then my change to the post-install script. "apt update" and "apt full-upgrade" seems to be working fine after that.
Of course this is not a fix and I think I did it worse: all calls to sleep will fail. But it was fun and Ubuntu WSL1 is not my main driver so I had nothing to lose ;)
Worked fine but it stops package manager to upgrade 3 packages to their previous state. But glad it worked...
mask your glibc version for package manager, keep it in version 2.30. it's different in different distribution, for Arch Linux, add glibc to IgnorePkg in /etc/pacman.conf, I don't know whether this will cause some version confliction, but for Arch Linux, nothing crash till today.
This is actually causing two problems on ArchWSL for me now:
The first is this old glibc blocks libxcrypt update. Because libxcrypt owns /usr/include/crypt.h/usr/lib/libcrypt.so now.
The second is that when I'm still on old glibc and didn't do any update, I can no longer use vscode-python renaming.
# uname -a
Linux [redacted] 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux# wslsys
Release Install Date: 0x5ceea999
Branch: 19h1_release
Build: 18363
Full Build: 18362.1.amd64fre.19h1_release.190318-1202
Uptime: 6d 4h 6m
Linux Release: Ubuntu Focal Fossa (development branch)
Linux Kernel: Linux 4.4.0-18362-Microsoft
Packages Count: 1367
# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libc-bin : Depends: libc6 (< 2.31) but 2.31-0ubuntu5 is installed
libc-dev-bin : Depends: libc6 (< 2.31) but 2.31-0ubuntu5 is installed
libc6-dev : Depends: libc6 (= 2.30-0ubuntu3) but 2.31-0ubuntu5 is installed
locales : Depends: libc-bin (> 2.31) but 2.30-0ubuntu3 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
# apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
libc-bin libc-dev-bin libc6-dev libcrypt-dev
Suggested packages:
glibc-doc
The following NEW packages will be installed:
libcrypt-dev
The following packages will be upgraded:
libc-bin libc-dev-bin libc6-dev
3 upgraded, 1 newly installed, 0 to remove and 131 not upgraded.
2 not fully installed or removed.
Need to get 0 B/3331 kB of archives.
After this operation, 44.0 kB disk space will be freed.
Do you want to continue? [Y/n]
Setting up libc6:amd64 (2.31-0ubuntu5) ...
Checking for services that may need to be restarted...
Checking init scripts...
Nothing to restart.
sleep: cannot read realtime clock: Invalid argument
dpkg: error processing package libc6:amd64 (--configure):
installed libc6:amd64 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
libc6:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
I "fixed" it somehow on my install. Because the error is in the postinstall script of libc6 package, I simply edited /var/lib/dpkg/info/libc6:amd64.postinst and transformed "sleep 1" in "echo sleep 1".
Then I run, as advised, 'apt --fix-broken install' and it managed to fix the dependencies. I removed then my change to the post-install script. "apt update" and "apt full-upgrade" seems to be working fine after that.
Of course this is not a fix and I think I did it worse: all calls to sleep will fail. But it was fun and Ubuntu WSL1 is not my main driver so I had nothing to lose ;)
Worked fine but it stops package manager to upgrade 3 packages to their previous state. But glad it worked...
Akash Kaushal (@hellohackie) : Thanks for your workaround, now let me expand on that.. You can work around this even more by installing busybox-static and using:
alias sleep='busybox sleep '
Observe:
$ strace -s 4096 -t -ff busybox sleep 3s
03:50:16 execve("/usr/bin/busybox", ["busybox", "sleep", "3s"], 0x7ffff0586030 /* 41 vars */) = 0
03:50:17 brk(NULL) = 0x1384000
03:50:17 brk(0x1385200) = 0x1385200
03:50:17 arch_prctl(ARCH_SET_FS, 0x13848c0) = 0
03:50:17 uname({sysname="Linux", nodename="D5DZ5WT2", ...}) = 0
03:50:17 readlink("/proc/self/exe", "/usr/bin/busybox", 4096) = 16
03:50:17 brk(0x13a6200) = 0x13a6200
03:50:17 brk(0x13a7000) = 0x13a7000
03:50:17 prctl(PR_SET_NAME, "busybox") = 0
03:50:17 getuid() = 1000
03:50:17 stat("/etc/busybox.conf", 0x7fffc7fe3998) = -1 ENOENT (No such file or directory)
03:50:17 getgid() = 1000
03:50:17 setgid(1000) = 0
03:50:17 setuid(1000) = 0
03:50:17 nanosleep({tv_sec=3, tv_nsec=0}, 0x7fffc7fe3a58) = 0
03:50:20 exit_group(0) = ?
03:50:20 +++ exited with 0 +++
$ date;sleep 3;date
Wed 26 Aug 2020 03:51:45 AM EDT
Wed 26 Aug 2020 03:51:48 AM EDT
$ /usr/lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Debian GLIBC 2.31-2) stable release version 2.31.
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 10.1.0.
libc ABIs: UNIQUE IFUNC ABSOLUTE
For bug reporting instructions, please see:
<http://www.debian.org/Bugs/>.
I prefer this solution, it seems less invasive than installing a patched glibc.
Create this file called nanosleep.c
#include<time.h>#include<unistd.h>// This restores the old behaviour of nanosleep() to use CLOCK_MONOTONIC.//// "POSIX.1 specifies that nanosleep() should measure time against the// CLOCK_REALTIME clock. However, Linux measures the time using the// CLOCK_MONOTONIC clock. This probably does not matter [...]"//// # gcc -shared -fPIC -o /usr/local/lib/libnanosleep.so nanosleep.c// # echo /usr/local/lib/libnanosleep.so >> /etc/ld.so.preload//intnanosleep(conststructtimespec*req, structtimespec*rem)
{
returnclock_nanosleep(CLOCK_MONOTONIC, 0, req, rem);
}
intusleep(useconds_tusec)
{
structtimespecreq= {
.tv_sec= (usec / 1000000),
.tv_nsec= (usec % 1000000) *1000,
};
returnnanosleep(&req, NULL);
}
This issue is fixed for Insiders in the Beta channel and the Release Preview channel with 20H2 Build 19042.487 (KB4571744). I would recommend reversing any custom changes to your WSL once you've updated.
Activity
sirredbeard commentedon Feb 14, 2020
Guidance on this issue in Ubuntu on WSL1 is here: https://discourse.ubuntu.com/t/ubuntu-20-04-and-wsl-1/15291:
Workarounds include:
If you need to reset Ubuntu and are on WSL 1, you should switch to the Ubuntu 18.04 image.
I can confirm upgrading glibc from 2.30.3 to 2.31.1 on Arch on WSL breaks sleep.
I used the Arch rootfs from the ArchWSL project: https://github.com/yuk7/ArchWSL/releases/download/20.2.7.0/Arch.zip
Imported it.
Confirmed 2.20.3 installed:
$ pacman -Q --info glibcIn /etc/pacman.conf changed SigLevel= to Never.
Ran updates:
$ pacman -SyuConfirmed new version:
$ pacman -Q --info glibcTried
$ sleep 10. Got came error.strace attached.
sleep10.txt
sirredbeard commentedon Feb 15, 2020
It looks like sleep used to call:
sleep10-glibc2.30-3.txt
Appears that support for nanosleep was added in 14915.
But now calls:
sleep10-glibc2.31-1.txt
The line in sleep is here: https://github.com/coreutils/coreutils/blob/master/src/sleep.c#L142
Here are the release notes for glibc 2.31.1, they mention some changes related to clock issues but nothing jumps out as directly related: https://sourceware.org/ml/libc-announce/2020/msg00001.html
Also this may all technically be a duplicate of #2503
therealkenc commentedon Feb 15, 2020
Most def. Apologies I saw this submission and knew it was dupe #2503 earlier in the afternoon, but got pulled away before I could hit the button. Thanks for going down the rabbit hole.
I'll forward-dupe #2503 as a (probably bad precedent) bump. If this is in glibc it'll hit distros in the store soon enough. Presumably eating
CLOCK_REALTIMEbut providingCLOCK_MONOTONICsemantics in the WSL1 driver would be a pretty small change.sirredbeard commentedon Feb 15, 2020
Between glibc 2.30 and 2.31 they add the following to /posix/nanosleep.c:
therealkenc commentedon Feb 15, 2020
Right, this.
sirredbeard commentedon Feb 15, 2020
Here an interesting related email thread:
therealkenc commentedon Feb 15, 2020
Yeah. Ref.
dbz2k commentedon Feb 15, 2020
I was wondering would issues like these get backported to with cumulative updates, or I would I have to wait till the next window version.
sirredbeard commentedon Feb 15, 2020
I spoke with one of the senior engineers on our foundations team and they do plan to land glibc 2.31, with the problematic change, in Ubuntu Focal 20.04, our next release in April.
This one would be a useful to have backported unless it can be fixed upstream.
dbz2k commentedon Feb 24, 2020
sorry for commenting again I was wondering if there were going to have wait till the next window version to get it fixed?
SvenGroot commentedon Feb 27, 2020
As therealkenc surmised, the issue is the lack of CLOCK_REALTIME support in WSL1's clock_nanosleep. We have a fix working internally, which will make its way to insiders. We will also look into backporting this to older Windows versions, but I can't make any promises or provide a timeline for this, unfortunately.
123 remaining items
SuperSandro2000 commentedon Aug 4, 2020
J (@jiucenglou) so you have libc6-dev installed?
juliomaranhao commentedon Aug 4, 2020
J (@jiucenglou) If you want to compile some C or C++, them install at least the "build-essential" ubuntu/debian meta package. Save this hint in your knowledge base.
build-essential is sufficient to compile nanosleep.c tiny C code.
jiucenglou commentedon Aug 5, 2020
Sandro (@SuperSandro2000) Júlio Maranhão (@juliomaranhao) Many thanks ! I failed to install build-essential because sleep was broken. The problem was then solved by using another fresh Ubuntu 20.04 instance.
hzhangxyz commentedon Aug 8, 2020
hellohackie commentedon Aug 14, 2020
Worked fine but it stops package manager to upgrade 3 packages to their previous state. But glad it worked...
CaliforniaMountainSnake commentedon Aug 21, 2020
I have this problem on Ubuntu 20.04 from windows store, but not on Ubuntu 18.04. Debian also works fine.
escape0707 commentedon Aug 22, 2020
This is actually causing two problems on ArchWSL for me now:
The first is this old
glibcblockslibxcryptupdate. Becauselibxcryptowns/usr/include/crypt.h/usr/lib/libcrypt.sonow.The second is that when I'm still on old
glibcand didn't do any update, I can no longer use vscode-python renaming.enihcam commentedon Aug 23, 2020
I got the following error:
ps: /usr/lib/libc.so.6: version 'GLIBC_2.32' not found (required by /usr/lib/libsystemd.so.0)Any suggestions?
escape0707 commentedon Aug 23, 2020
klikevil commentedon Aug 26, 2020
This also effects Kali, any chance you will have this fixed anytime soon?
klikevil commentedon Aug 26, 2020
Akash Kaushal (@hellohackie) : Thanks for your workaround, now let me expand on that.. You can work around this even more by installing busybox-static and using:
alias sleep='busybox sleep 'Observe:
TanguyOrtegat commentedon Aug 26, 2020
last line didn't work for me, but changing the command a bit, and worked!
here it is:
sudo sh -c "echo /usr/local/lib/libnanosleep.so >> /etc/ld.so.preload"jordan-wirth commentedon Aug 27, 2020
This issue is fixed for Insiders in the Beta channel and the Release Preview channel with 20H2 Build 19042.487 (KB4571744). I would recommend reversing any custom changes to your WSL once you've updated.