Skip to content

bash -c fish hanging indefinitely #1653

Closed

Description

Attempting to start my upgraded installation of fish shell via bash.exe (bash -c fish) causes bash.exe to hang indefinitely. I have attached a full dump of bash.exe in this state: bash.zip

This is on Windows 10 build 15014.

Launching bash then executing fish works just fine. Launching any other shell via bash -c ... (e.g. sh) also works just fine.

This did not use to happen until I updated my fish installation.

mqudsi@ZBook /m/c/U/Mahmoud> fish --version
fish, version 2.4.0-472-gf48291b

Activity

  1. benhillis commented on Feb 1, 2017

    @benhillis
    Member

    I can't reproduce this on [Version 10.0.15026]. Are there any other steps specific to your configuration?

    This is what I did:

    1. sudo apt install fish
    2. bash.exe -c fish
    C:\Users\benhill>bash.exe -c fish
    Welcome to fish, the friendly interactive shell
    Type help for instructions on how to use fish
    benhill@BENHILL-X1 /m/c/U/benhill>
    
  2. mqudsi commented on Feb 1, 2017

    @mqudsi
    Author

    Yes, fish worked fine when installed that way for me too. However, when I manually compiled it from git to run the latest version, I ran into the problem described above.

    Since I think bash on Windows is ABI stable, I've attached a copy of my own fish binary here. Otherwise, you can build it yourself from https://github.com/fish-shell/fish-shell

    fish.gz

  3. changed the title [-]`bash -c` hanging indefinitely[/-] [+]`bash -c fish` hanging indefinitely[/+] on Feb 1, 2017
  4. therealkenc commented on Feb 2, 2017

    @therealkenc

    Here's the gist for version 2.4.0-477-g44cfe3e, tail end below. It only hangs when run from bash -c. Runs fine if launched from bash inside WSL. Code in question seems to be here. I bisected a little, but just to make life difficult that tcsetpgrp() appears to be in 2.2.0 (which works fine) as well.

    Note this exited below because of ctrl-c, otherwise it just hangs forever.

    ioctl(1, TCGETS, {B38400 opost isig -icanon -echo ...}) = 0
    ioctl(1, TCGETS, {B38400 opost isig -icanon -echo ...}) = 0
    ioctl(1, TIOCGWINSZ, {ws_row=47, ws_col=120, ws_xpixel=0, ws_ypixel=0}) = 0
    getpgrp()                               = 225
    ioctl(0, TIOCGPGRP, [225])              = 0
    getpgrp()                               = 225
    setpgid(228, 228)                       = 0
    ioctl(0, TIOCSPGRP, [228])              = -1 EINTR (Interrupted system call)
    --- SIGTTOU {si_signo=SIGTTOU, si_code=SI_KERNEL} ---
    strace: Process 228 detached
    <E> fish: Couldn't grab control of terminal
    tcsetpgrp: Interrupted system call
    
  5. vb4life commented on Jun 7, 2017

    @vb4life

    Might not be related, but after I upgraded to fish, version 2.6.0 it started hanging when launched. The difference is that I added fish to my .bashrc. If i started it manually, everything was fine.

    I managed to solve it by just creating an empty fish.config file:
    # touch ~/.config/fish/config.fish

    This might be a completely different issue, but was the only thing a quick google search could find :)

  6. mqudsi commented on Jul 9, 2017

    @mqudsi
    Author

    Ben Hillis (@benhillis) any chance of an update on this? Do you think it's related to the other fish issues?

  7. mqudsi commented on Jul 12, 2017

    @mqudsi
    Author

    Just an update: the latest fish compiled from git does not exhibit this problem; but not because the issue went away. Bisecting the changes between g44cfe3e and b88cacf03eb5717cf2ecaaa6ab4632bc7f7632d5 and comparing that to the previous bisect logs for when the problem was introduced (aside from being a nightmare) should be enlightening.

  8. therealkenc commented on Jul 12, 2017

    @therealkenc

    Curious. Nothing obvious changed in fish with respect to the relevant code recently.

    Interestingly fish does have a test for WSL here. But it's unrelated AFAICT. I could be missing something on both counts, of course.

  9. mqudsi commented on Aug 20, 2017

    @mqudsi
    Author

    OK, so it's not something in the fish source code. I updated to the latest fish code and rebuilt and installed only for it to begin hanging once more. I decided to git bisect the problem, except reverting to the commit I noted in my previous build as working did not work this time around.

    I'm having a hard time figuring this one out since running with full debug logging doesn't reveal anything interesting. The diff between the successful start and the failed start is also not very interesting.

    Trying to debug with gdb causes the hung fish process to crash on attach, before gdb gets a chance to hook in and results in no stack trace. Launching fish under gdb hangs both gdb and fish when launched and neither responds to SIGINT .

    I thought it might have something to do with the compiler; last time around I compiled with g++ but I'm not sure which version, while this time was with clang++ 4.0; so I tried to rebuild with g++ 7, but that wasn't it.

  10. mqudsi commented on Aug 20, 2017

    @mqudsi
    Author

    I tracked it down to the following code:

        debug(0, L"calling tcsetpgrp for fd %d for pgid %d\n", STDIN_FILENO, shell_pgid);
        if (tcsetpgrp(STDIN_FILENO, shell_pgid) == -1) {
            debug(0, L"tcsetpgrp failed\n");
            if (errno == ENOTTY) redirect_tty_output();
            debug(0, _(L"Couldn't grab control of terminal"));
            wperror(L"tcsetpgrp");
            exit_without_destructors(1);
        }
        debug(0, L"tcsetpgrp ok\n");

    This hangs after printing "calling tcsetpgrp ...", like reported by therealkenc above.
    This same code worked the last time I compiled the same code.. and now it doesn't. It wasn't that fish worked and now it doesn't, it's it worked until I recompiled and reinstalled the same code and now it doesn't.

    I'm obviously not suggesting a gremlin or anything of that nature; I imagine it has something to do with the loaded state or something that is reset on install, a conflict between bash and fish, etc.

  11. lepinekong commented on Mar 5, 2018

    @lepinekong

    I confirm that it freezes.

  12. mathewhany commented on Apr 2, 2018

    @mathewhany

    I don't know if this could help anyone, but I managed to workaround this problem, I'm using Hyper as a terminal, and what I did is:

    1. I followed the installation guide to install fish.
    sudo apt-add-repository ppa:fish-shell/release-2
    sudo apt-get update
    sudo apt-get install fish
    
    1. Then, I installed Oh My Fish (However, I don't think installing it made any difference to the problem).
    curl -L https://get.oh-my.fish | fish
    
    1. I edited .bashrc, I added at the end:
    if [ -t 1 ]; then
      exec fish
    fi
    
    1. In .hyper.js, I edited it like this:
    shell: 'bash.exe',
    shellArgs: ['--login'],
    
  13. Michael137 commented on Apr 22, 2018

    @Michael137

    Interestingely, it hangs when I simply start ubuntu.exe, but doesn't hang when i start wsl.exe first followed by ubuntu.exe

  14. therealkenc commented on May 24, 2018

    @therealkenc

    Brian marked this as fixed in October 2017. Taking his word that something was fixed related to the OP at that time. I just tried wsl.exe /usr/bin/fish -c ls and it appears to work. This was on 17672 and Ubuntu 18.04 (fish 2.7.1).

  15. added a commit that references this issue on Oct 31, 2018
  16. added a commit that references this issue on Nov 13, 2018
  17. added a commit that references this issue on Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions