microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.04k stars 797 forks source link

init loops with SIGSEGV #7901

Open cg2v opened 2 years ago

cg2v commented 2 years ago

Version

Microsoft Windows [Version 10.0.19044.1415]

WSL Version

Kernel Version

4.4.0-19041-Microsoft

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

Start WSL from windows terminal

Expected Behavior

cpu usage stays about the same

Actual Behavior

init process is using 15-19% until it exits Each additional tab consumes 15% until 100% usage is reached

Diagnostic Logs

Strace shows this on repeat, for the process that is bash's parent (not pid 1): --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x3e9e06139} ---

This address appears to be consistent, and is not near any of the processes mapped memory:

$ cat /proc/195/maps
00200000-00225000 r--p 00000000 00:00 105698                     /init
00225000-00226000 r--p 00025000 00:00 105698                     /init
00226000-00294000 r-xp 00026000 00:00 105698                     /init
00294000-00295000 r-xp 00094000 00:00 105698                     /init
00295000-0029c000 rw-p 00095000 00:00 105698                     /init
0029c000-002a2000 rw-p 00000000 00:00 0
01e06000-01e09000 rw-p 00000000 00:00 0                          [heap]
7f7f8a590000-7f7f8a591000 ---p 00000000 00:00 0
7f7f8a591000-7f7f8a5a6000 rw-p 00000000 00:00 0
7ffff38b6000-7ffff40b6000 rw-p 00000000 00:00 0                  [stack]
7ffff45b2000-7ffff45b3000 r-xp 00000000 00:00 0                  [vdso]
cg2v commented 2 years ago

(I am using WSL1 because I am affected by #5068)

elsaco commented 2 years ago

@cg2v what is the output of pstree -p?

cg2v commented 2 years ago
cg2v@MAYA:~$ pstree -p
init(1)─┬─init(10)───bash(11)
        ├─init(96)───bash(97)───pstree(182)
        └─{init}(9)

In this case, it is pids 10 and 96 that are spinning.

rar222 commented 2 years ago

I'm relatively certain that I'm suffering from exactly the same problem.

Start WSL - A Ubuntu 20.04.2 LTS image that i've been using for >12 months, and init goes immediately to 100% CPU

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   56 root      20   0    8944    224    184 R  99.0   0.0   0:33.90 init                                               

I've just done a bunch of Windows updates which have changed WSL - given that yesterday starting WSL wasn't going to my home directory any more.

strace shows similar:

--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x3e8634137} ---
laptop:~>  cat /proc/56/maps
00200000-00225000 r--p 00000000 00:00 1613571                    /init
00225000-00226000 r--p 00025000 00:00 1613571                    /init
00226000-00294000 r-xp 00026000 00:00 1613571                    /init
00294000-00295000 r-xp 00094000 00:00 1613571                    /init
00295000-0029c000 rw-p 00095000 00:00 1613571                    /init
0029c000-002a2000 rw-p 00000000 00:00 0
00634000-00637000 rw-p 00000000 00:00 0                          [heap]
7fac76b80000-7fac76b81000 ---p 00000000 00:00 0
7fac76b81000-7fac76b96000 rw-p 00000000 00:00 0
7ffff041d000-7ffff0c1d000 rw-p 00000000 00:00 0                  [stack]
7ffff0e3d000-7ffff0e3e000 r-xp 00000000 00:00 0                  [vdso]
rar222 commented 2 years ago

If I open wsl from the standard cmd screen with "wsl.exe" then it's fine.

If I open cmd from Windows Terminal, then run "wsl.exe" then it's fine.

If I open wsl directly from Windows Terminal then init jumps to 100% and sits there until I kill the session (close the terminal)

If I open the Windows Terminal settings and remove the

        "startingDirectory": "/home/rar222"

Then it

  1. No longer opens in my home directory - I needed to use the windows path \\wsl$\Ubuntu\home\rar222\
  2. No longer makes init go insane

So for me a workaround is to remove that setting

koreno commented 10 months ago

If I open wsl from the standard cmd screen with "wsl.exe" then it's fine.

If I open cmd from Windows Terminal, then run "wsl.exe" then it's fine.

If I open wsl directly from Windows Terminal then init jumps to 100% and sits there until I kill the session (close the terminal)

If I open the Windows Terminal settings and remove the

        "startingDirectory": "/home/rar222"

Then it

  1. No longer opens in my home directory - I needed to use the windows path \\wsl$\Ubuntu\home\rar222\
  2. No longer makes init go insane

So for me a workaround is to remove that setting

Had the same experience, just with using Tabby, had to remove the "--cd " param from the cmdline...