[Bug 1871129] Re: htop is blank when using in focal in wsl1

Balint Reczey 1871129 at bugs.launchpad.net
Mon Sep 14 20:17:19 UTC 2020


Tested with 2.31-0ubuntu9.1 on Focal running on Windows 10 build 19041
in WSL1:

]0;ubuntu at DESKTOP-GOODMAK: ~ubuntu at DESKTOP-GOODMAK:~$ ./a.out 
Sleep 1.5s with TIMER_ABSTIME
sleep 1.2s
sleep 1.2s with CLOCK_MONOTONIC
invalid sleep -1s (+200ms)
invalid sleep 1s (-200ms)
invalid sleep 0s (+1.200ms as nsec)
]0;ubuntu at DESKTOP-GOODMAK: ~ubuntu at DESKTOP-GOODMAK:~$ ./a.out [1 at s[1 at t[1 at r[1 at a[1 at c[1 at e[1@ 
execve("./a.out", ["./a.out"], 0x7ffffa6eaab0 /* 19 vars */) = 0
brk(NULL)                               = 0x7ffff34aa000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffffb11f4e0) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=29824, ...}) = 0
mmap(NULL, 29824, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe759f58000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360q\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0", 32, 848) = 32
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\363\377?\332\200\270\27\304d\245n\355Y\377\t\334"..., 68, 880) = 68
fstat(3, {st_mode=S_IFREG|0755, st_size=2029224, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe759f90000
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0", 32, 848) = 32
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\363\377?\332\200\270\27\304d\245n\355Y\377\t\334"..., 68, 880) = 68
mmap(NULL, 2036952, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe759d60000
mprotect(0x7fe759d85000, 1847296, PROT_NONE) = 0
mmap(0x7fe759d85000, 1540096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7fe759d85000
mmap(0x7fe759efd000, 303104, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19d000) = 0x7fe759efd000
mmap(0x7fe759f48000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7fe759f48000
mmap(0x7fe759f4e000, 13528, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe759f4e000
close(3)                                = 0
arch_prctl(ARCH_SET_FS, 0x7fe759f91380) = 0
mprotect(0x7fe759f48000, 12288, PROT_READ) = 0
mprotect(0x7fe759f97000, 4096, PROT_READ) = 0
mprotect(0x7fe759f8d000, 4096, PROT_READ) = 0
munmap(0x7fe759f58000, 29824)           = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1600117863, tv_nsec=617308900}) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
brk(NULL)                               = 0x7ffff34aa000
brk(0x7ffff34cb000)                     = 0x7ffff34cb000
write(1, "Sleep 1.5s with TIMER_ABSTIME\n", 30Sleep 1.5s with TIMER_ABSTIME
) = 30
clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, {tv_sec=1600117865, tv_nsec=117308900}, 0x7ffffb11f4a0) = -1 EINVAL (Invalid argument)
clock_gettime(CLOCK_REALTIME, {tv_sec=1600117863, tv_nsec=624035400}) = 0
clock_nanosleep(CLOCK_MONOTONIC, 0, {tv_sec=1, tv_nsec=493273500}, 0x7ffffb11f4a0) = 0
write(1, "sleep 1.2s\n", 11sleep 1.2s
)            = 11
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=200000000}, 0x7ffffb11f4a0) = -1 EINVAL (Invalid argument)
clock_nanosleep(CLOCK_MONOTONIC, 0, {tv_sec=1, tv_nsec=200000000}, 0x7ffffb11f4a0) = 0
write(1, "sleep 1.2s with CLOCK_MONOTONIC\n", 32sleep 1.2s with CLOCK_MONOTONIC
) = 32
clock_nanosleep(CLOCK_MONOTONIC, 0, {tv_sec=1, tv_nsec=200000000}, 0x7ffffb11f4a0) = 0
write(1, "invalid sleep -1s (+200ms)\n", 27invalid sleep -1s (+200ms)
) = 27
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=-1, tv_nsec=200000000}, 0x7ffffb11f4a0) = -1 EINVAL (Invalid argument)
write(1, "invalid sleep 1s (-200ms)\n", 26invalid sleep 1s (-200ms)
) = 26
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=18446744073509551616}, 0x7ffffb11f4a0) = -1 EINVAL (Invalid argument)
write(1, "invalid sleep 0s (+1.200ms as ns"..., 36invalid sleep 0s (+1.200ms as nsec)
) = 36
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=1200000000}, 0x7ffffb11f4a0) = -1 EINVAL (Invalid argument)
exit_group(0)                           = ?
+++ exited with 0 +++
]0;ubuntu at DESKTOP-GOODMAK: ~ubuntu at DESKTOP-GOODMAK:~$ exit

** Tags removed: verification-needed verification-needed-focal
** Tags added: verification-done verification-done-focal

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to glibc in Ubuntu.
https://bugs.launchpad.net/bugs/1871129

Title:
  htop is blank when using in focal in wsl1

Status in Ubuntu WSL:
  In Progress
Status in glibc package in Ubuntu:
  Fix Released
Status in htop package in Ubuntu:
  Invalid
Status in glibc source package in Focal:
  Fix Committed

Bug description:
  [Impact]

  Programs previously using nanosleep syscall and with glibc 31's update
  being switched to use clock_nanosleep broke due to clock_nanosleep
  using CLOCK_REALTIME returns EINVAL in wsl1.

  [Test Case]

  Run sleep in WSL1 on Windows 10 2004 or older version.
  The fixed version works correctly, the not fixed version breaks in Focal.

  Run the following program under in WSL1 and on a real kernel with
  strace and observe that the fallback is applied only when it is
  needed:

  #include <time.h>
  #include <stdio.h>

  int main (int argc, char ** argv) {
   struct timespec ts, rem;
         clock_gettime(CLOCK_REALTIME, &ts);
   printf("Sleep 1.5s with TIMER_ABSTIME\n");
   ts.tv_nsec += 500000000L;
   if (ts.tv_nsec > 1000000000L) {
    ts.tv_nsec -= 1000000000L;
      ts.tv_sec += 1;
   }
   ts.tv_sec += 1;
   clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts, &rem);

   printf("sleep 1.2s\n");
   ts.tv_sec = 1;
   ts.tv_nsec = 200000000L;
   clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem);

   printf("sleep 1.2s with CLOCK_MONOTONIC\n");
   ts.tv_sec = 1;
   ts.tv_nsec = 200000000L;
   clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &rem);

   printf("invalid sleep -1s (+200ms)\n");
   ts.tv_nsec = 200000000L;
   ts.tv_sec = -1;
   clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem);

   printf("invalid sleep 1s (-200ms)\n");
   ts.tv_nsec = -200000000L;
   ts.tv_sec = 1;
   clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem);

   printf("invalid sleep 0s (+1.200ms as nsec)\n");
   ts.tv_nsec = 1200000000L;
   ts.tv_sec = 1;
   clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem);

  }

  [Regression Potential]

  The fix is falling back to using monotonic time and also converts the clock_nanosleep call to not use TIMER_ABSTIME in the fallback.
  If the calculation from absolute to relative time is not correct then it may result in a very long sleep effectively hanging the calling process.
  Also the checks in the callback can crash the calling program if a mistake is made.
  The program in the [Test] section aims to cover all branches of the fix.

  [Original Bug Text]

  Right now I am trying Ubuntu 20.04 on WSL and I noticed that when I
  run htop in WSL 1st generation, it is completely blank:

  https://user-images.githubusercontent.com/15316889/78563857-31697b00
  -784e-11ea-9f21-338a6cf8cb23.gif

  The previous version (htop 2.1.0) works without any issue.

  I am using htop 2.2.0-2build1 on Ubuntu 20.04 on WSL1 on Windows 10
  build 19592.1001.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntuwsl/+bug/1871129/+subscriptions



More information about the foundations-bugs mailing list