fish-shell / fish-shell

The user-friendly command line shell.

Home Page:https://fishshell.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fish hangs in futex() during start in VS Code’s integrated terminal

TimWolla opened this issue · comments

When I attempt to launch VS Code’s integrated terminal, fish hangs during startup. This likely is a regression that happened somewhere between 3.6.0-142-gacde38fed-1~focal and 3.7.1-1899-g29f2da8d1-1~focal. Unfortunately I can't confirm more exactly, because I no longer have the package for the old version and I don't have a Rust compiler available either.

fish version: fish, version 3.7.1-1932-g8c62f733b
VS Code Version:

Version: 1.89.1
Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685
Date: 2024-05-07T05:16:23.416Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Linux x64 5.4.0-186-generic

Operating System: Ubuntu 20.04, Linux *snip* 5.4.0-186-generic #206-Ubuntu SMP Fri Apr 26 12:31:10 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

$TERM: xterm-256color

It works when launching fish as env HOME=$(mktemp -d) XDG_CONFIG_HOME= fish. It doesn't work when I launch fish just using fish:

bash $ env HOME=$(mktemp -d) XDG_CONFIG_HOME= fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
timwolla@*snip* /h/t/S/*snip* (*snip*)> 
bash $ fish
^C

strace -f -yyyy -ttt fish returns the following and then hangs:

*snip*
1716320891.402739 openat(AT_FDCWD, "/home/timwolla/.config/fish/fish_variables", O_RDONLY|O_CLOEXEC) = 3</home/timwolla/.config/fish/fish_variables>
1716320891.402815 fstat(3</home/timwolla/.config/fish/fish_variables>, {st_mode=S_IFREG|0644, st_size=3782, ...}) = 0
1716320891.402899 read(3</home/timwolla/.config/fish/fish_variables>, "# This file contains fish univer"..., 4096) = 3782
1716320891.402982 read(3</home/timwolla/.config/fish/fish_variables>, "", 4096) = 0
1716320891.403181 close(3</home/timwolla/.config/fish/fish_variables>) = 0
1716320891.403343 statx(AT_FDCWD, "/home/timwolla/.terminfo", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffe5f7a9510) = -1 ENOENT (No such file or directory)
1716320891.403644 statx(AT_FDCWD, "/etc/terminfo", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFDIR|0755, stx_size=4096, ...}) = 0
1716320891.403710 statx(AT_FDCWD, "/etc/terminfo/x/xterm-256color", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffe5f7a9510) = -1 ENOENT (No such file or directory)
1716320891.403768 statx(AT_FDCWD, "/etc/terminfo/78/xterm-256color", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffe5f7a9510) = -1 ENOENT (No such file or directory)
1716320891.403847 statx(AT_FDCWD, "/lib/terminfo", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFDIR|0755, stx_size=4096, ...}) = 0
1716320891.403927 statx(AT_FDCWD, "/lib/terminfo/x/xterm-256color", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=3503, ...}) = 0
1716320891.404018 openat(AT_FDCWD, "/lib/terminfo/x/xterm-256color", O_RDONLY|O_CLOEXEC) = 3</lib/terminfo/x/xterm-256color>
1716320891.404134 statx(3</lib/terminfo/x/xterm-256color>, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=3503, ...}) = 0
1716320891.404222 lseek(3</lib/terminfo/x/xterm-256color>, 0, SEEK_CUR) = 0
1716320891.404296 read(3</lib/terminfo/x/xterm-256color>, "\36\2%\0&\0\17\0\235\1\356\5xterm-256color|xterm"..., 3503) = 3503
1716320891.404396 read(3</lib/terminfo/x/xterm-256color>, "", 32) = 0
1716320891.404668 close(3</lib/terminfo/x/xterm-256color>) = 0
1716320891.405080 futex(0x55bb2e731590, FUTEX_WAIT_BITSET_PRIVATE, 2, NULL, FUTEX_BITSET_MATCH_ANY

I'm happy to provide additional information or config files on request. I'm also happy to try out changes to the config, but I didn't want to blindly try out changes to not risk breaking anything else in case you already have a good idea based on the existing information.

It works when launching fish as env HOME=$(mktemp -d) XDG_CONFIG_HOME= fish. It doesn't work when I launch fish just using fish:

That means it's triggered by your configuration.

Ideally you'd find which part is responsible and reduce it to a test case.

Unfortunately the strace doesn't say a lot - it reads terminfo, successfully and then blocks on something that boils down to a futex? I do not see a futex call anywhere close to that spot.

I installed VS Code to test and can't reproduce this either.

Thank you for your prompt reply. I was able to boil this down to a minimal configuration. It appears to be related to the LC_ALL environment variable being set.

See the following transcript (using bash inside VS Code’s terminal):

timwolla@*snip*:~$ find /tmp/fish-config/
/tmp/fish-config/
/tmp/fish-config/.config
/tmp/fish-config/.config/fish
/tmp/fish-config/.config/fish/fish_variables
timwolla@*snip*:~$ cat /tmp/fish-config/.config/fish/fish_variables 
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR --export LC_ALL:en_US\x2eUTF\x2d8
SETUVAR __fish_init_1_22_0:\x1d
SETUVAR __fish_init_1_50_0:\x1d
SETUVAR __fish_init_2_3_0:\x1d
SETUVAR __fish_init_3_1_0:\x1d
SETUVAR __fish_init_3_x:\x1d
SETUVAR __fish_initialized:3800
SETUVAR __prompt_initialized_2:\x1d
timwolla@*snip*:~$ env HOME=/tmp/fish-config/ XDG_CONFIG_HOME= fish
# Hangs
^C
timwolla@*snip*:~$ sed -i '/LC_ALL/d' /tmp/fish-config/.config/fish/fish_variables
timwolla@*snip*:~$ cat /tmp/fish-config/.config/fish/fish_variables 
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR __fish_init_1_22_0:\x1d
SETUVAR __fish_init_1_50_0:\x1d
SETUVAR __fish_init_2_3_0:\x1d
SETUVAR __fish_init_3_1_0:\x1d
SETUVAR __fish_init_3_x:\x1d
SETUVAR __fish_initialized:3800
SETUVAR __prompt_initialized_2:\x1d
timwolla@*snip*:~$ env HOME=/tmp/fish-config/ XDG_CONFIG_HOME= fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
timwolla@*snip* /h/timwolla> 
timwolla@*snip*:~$ 

And indeed I'm able to kill a fresh fish configuration by setting that variable:

timwolla@*snip*:~$ rm -r /tmp/fresh-fish-config/
timwolla@*snip*:~$ env HOME=/tmp/fresh-fish-config XDG_CONFIG_HOME= fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
timwolla@*snip* /h/timwolla> set -x -U LC_ALL en_US.UTF-8
set: successfully set universal 'LC_ALL'; but a global by that name shadows it
timwolla@*snip* /h/timwolla> 
timwolla@*snip*:~$ env HOME=/tmp/fresh-fish-config XDG_CONFIG_HOME= fish
^C

I can reproduce. A crucial piece is that LC_ALL is already exported from bash to fish, hence the warning about universals

bisects to 77aeb6a (Port execution, 2023-10-08). Probably a deadlock reading variables

Awesome turn-around time. Thank you!

I'm just excited someone else is actually running the development builds ;-)

Going by my issues (https://github.com/fish-shell/fish-shell/issues?q=is%3Aissue+is%3Aclosed+author%3ATimWolla), I've used them for almost 8 years. Just 14 issues in that time, with 5 years since the last issue, is a statement of quality 😄