mintty / wsltty

Mintty as a terminal for Bash on Ubuntu on Windows / WSL
Other
3.11k stars 104 forks source link

WSL Terminal always closes immediately - How to debug #156

Closed kmille closed 5 years ago

kmille commented 5 years ago

Hey,

my WSL Terminal always closes immediately after starting it and I don't know why or how to debug it. I used wsltty-1.9.6-install.exe to install it. I use the Ubuntu 18.04 Image from the Windows Store on a Windows 10 Laptop.

That's how I call it: H:>%LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL= --configdir="%APPDATA%\wsltty" -~ -V

The config file in "%APPDATA%\wsltty" is emtpy. Can you please help me. I can't go back to the default shell

mintty commented 5 years ago

See the mintty manual page: -V Print version information and exit. Why did you add that option?

kmille commented 5 years ago

Hey that was just a test. I normally run in it without the -V so just %LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL= --configdir="%APPDATA%\wsltty" -~

mintty commented 5 years ago

Add option Hold=always to the config file.

kmille commented 5 years ago

sry for the late response: %LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL= --configdir="%APPDATA%\wsltty" -~ -h=always Should be the same behaviour like using the config. But I tried this before. No error message for me. The window is just closing again...

mintty commented 5 years ago

On the command line, the option is -h always without a =, or -o Hold=always.

kmille commented 5 years ago

unbenannt

mintty commented 5 years ago

Sure I like closed issues :) but that does not look like a solution for you‽

kmille commented 5 years ago

You are right. Sorry

kmille commented 5 years ago

Hey, it's working again. And I don't know why 😄 Probably Windows domain foo magic or Windows Updates ...

thanks for your support!

kmille commented 5 years ago

hm the problem occurs again -:- Any ideas what to do with an immediately closing WSL Terminal?

mintty commented 5 years ago

We've had the Hold option already, at least it should not close then. You should see some error message or other trace of what happens. Is this related to #153, #152? Maybe #135? Or rather #142?

mintty commented 5 years ago

Did you change the WSL mount path configuration? The solution for #91 might not be sufficient...

kmille commented 5 years ago

I will try it and give you feedback

jrhorn424 commented 5 years ago

I can connect to other distros fine, but not Alpine.

image

mintty commented 5 years ago

Reproduced, also when using wslbridge directly from cygwin. Navigating to /mnt/c/Users/.../wsltty/bin and trying to run wslbridge-backend directly also fails with ./wslbridge-backend: not found. That's weird; maybe Alpine has a safety policy not to run programs from Windows mounts? To test the latter assumption, I tried to copy wslbridge-backend into Alpine's /bin but that fails for permission right, also Alpine does not seem to support sudo - maybe it's a "closed shop"?

Biswa96 commented 5 years ago

@jrhorn424 From where did you download Alpine? Probable cause, Alpine uses MUSL C library for it's compactness feature. The wslbridge-backend is compiled with GNU C library. So, there is incompatibility between C library. For Alpine, you have to compile the wslbridge-backend from source. This issue may not be related with mintty.

mintty commented 5 years ago

Even though the backend Makefile contains options -static-libgcc -static-libstdc++ already?

Biswa96 commented 5 years ago

OK, I explain. When I compiled wslbridge-backend in Debian based distributions readelf -d wslbridge-backend shows:

Dynamic section at offset 0xd2898 contains 30 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libutil.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]

Now in Alpine, I did this:

jrhorn424 commented 5 years ago

Thank you, that works for me as well! Very much appreciated.

kmille commented 5 years ago

I still don't get it. It seems like the wslbridge is the problem. I use Terminus at the moment but it's pretty buggy if I use it with tmux. Should I ask at the wslbridge repo?

mintty commented 5 years ago

I've tried to follow Biswa's suggestion and compile wslbridge-backend in Alpine (commented out the strerror stuff) - with no success. You can report it to wslbridge but I wouldn't expect a solution in wslbridge itself (except for the strerror).

Biswa96 commented 5 years ago

@mintty Did you install bash in Alpine? Because wslbridge.exe depends on bash.exe which executes /bin/bash only. And Alpine /bin/busybox has not bash. @kmille's issue is different that @jrhorn424. @kmille is using Ubuntu.

mintty commented 5 years ago

OK, right, I overlooked the bash thing in your comment. Got it working. Then I tried to compile statically again, with the error wslbridge-backend.cc:(.text.startup+0x115b): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking This is strange. Anyway, I disabled the getpwuid part and, with -static added to the backend Makefile, it works, i.e. wslbridge-backend compiled with gcc (in "normal" WSL, not Alpine). I could also reenable the strerror stuff. So there is in fact an opportunity to cover Alpine with a common wslbridge-backend binary, if only we find a solution for the getpwuid crap.

And, for that matter, this is not the original issue opened here, but that was fuzzy anyway...

Biswa96 commented 5 years ago

wslbridge-backend.cc:(.text.startup+0x115b): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

@mintty That is known issue. See here https://github.com/rprichard/wslbridge/issues/26

mintty commented 5 years ago

I've tried to load getpwuid with dlopen but it did not work...

kmille commented 5 years ago

In the mantime: I works again #yail \o/ I still have no clue but I'm sure it's not a problem of mintty. It's probably caused by our domain foo. Thanks it adavance!

mintty commented 5 years ago

While the original problem (@kmille) may be a different issue, I think the Alpine/wslbridge-backend binary compatibility issue is solved by patching wslbridge-backend. I'll apply a patch that implements getpwuid directly by reading /etc/passwd, so static compilation will work.

Biswa96 commented 5 years ago

Isn't static compiling made it bigger binary file? And what is the difference between your patch and glibc implementation of getpwuid?

mintty commented 5 years ago

Size is ~1.7MB rather than 150KB. But it works. My getpwuid only checks /etc/passwd while there are other authentication mechanisms (network/domain controlled).

mintty commented 5 years ago

Released 3.0.1.

mintty commented 5 years ago

Reopened with 3.0.1.2, see #169.

mintty commented 5 years ago

Are there any other distributions that have this problem? If it's only Alpine, we could add an alternative, Alpine-compiled wslbridge-backend to the package, and make a choice based on the selected distribution.

itsjef commented 5 years ago

Are there any other distributions that have this problem? If it's only Alpine, we could add an alternative, Alpine-compiled wslbridge-backend to the package, and make a choice based on the selected distribution.

@mintty I am having the same issue with both Ubuntu 18.04.02 LTS and Debian

mintty commented 5 years ago

With Ubuntu, it's more likely #171. Please check your WSL version (1 or 2) for the distribution.

itsjef commented 5 years ago

@mintty My WSL version is 1, I'm also not participating in Windows Insiders anyway.

Biswa96 commented 5 years ago

It may be helpful if wsltty makes -h always a default option.

itsjef commented 5 years ago

Hmm I also added -h always but only got a blank window 🤔

image

mintty commented 5 years ago

I've installed Ubuntu 18.04 LTS and Debian, run Start Menu → WSLtty → configure WSL shortcuts, and it works for me.

mintty commented 5 years ago

Maybe there are other Windows/WSL changes, applicable to WSL version 1, that impede WSLtty function? Which version do you run?

itsjef commented 5 years ago

@mintty I ran Start Menu → WSLtty → configure WSL shortcuts for both version 3.0.1 and 3.0.1.2 but the problem still occured

itsjef commented 5 years ago

Is there a way I can create a crash log and upload it here so you guys can look into the issue? I think that will help.

mintty commented 5 years ago

Do you see a file wslbridge.exe.stackdump in either your %USERPROFILE%, %LOCALAPPDATA%\wsltty or %LOCALAPPDATA%\wsltty\bin folders? If there is one, we can try to set up something to debug it.

itsjef commented 5 years ago

@mintty I don't, is there an option to turn on stack dump?

mintty commented 5 years ago

If there is no crash happening, that would not help. It seems rather that either the wslbridge frontend or backends is stalled.

mintty commented 5 years ago

You can install a cygwin environment (https://cygwin.com/setup-x86_64.exe). Then, in a cygwin terminal, copy cp $LOCALAPPDATA/wsltty/bin/wslbridge* /bin. Invoke mintty --WSL manually, from a cygwin shell.

itsjef commented 5 years ago

I did it but the terminal still closed immediately. 🤔

mintty commented 5 years ago

closed immediately

You said before you get a blank window. That's not the same symptom. Any output if you force it to stay open with mintty -h alw --WSL?

itsjef commented 5 years ago

When I ran mintty -h alw --WSL, a blank window appeared, if I drop the -h alw then it would close immediately.

Occasionally the window will stay open and I can use it normally but it's very rare 😕

itsjef commented 5 years ago

I'm thinking it's a wslbridge issue. I have tried using goreliu/wsl-terminal but the window also opens and closes at once.

mintty commented 5 years ago

I'm thinking it's a wslbridge issue.

I thought so already but I have no idea how to proceed with analysis, remotely.

Occasionally the window will stay open ...

Oh. Well, WSL sometimes needs a while until startup has settled. If you only wait enough...?