Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish appears to hang on first startup #6295

Closed
mgedmin opened this issue Nov 7, 2019 · 9 comments
Closed

fish appears to hang on first startup #6295

mgedmin opened this issue Nov 7, 2019 · 9 comments
Labels
performance
Milestone

Comments

@mgedmin
Copy link

@mgedmin mgedmin commented Nov 7, 2019

I've been meaning to try out fish on several occasions (years apart), but I always stumble upon this issue.

On my system (various versions of Ubuntu, currently 19.10) I do

  • sudo apt install fish
  • fish

and what happens next:

  • no output
  • no prompt
  • laptop's fan spins up
  • nothing else happens for several minutes
  • I panic and kill fish that is eating all the CPU

On second run fish starts instantly.

I'm not sure how to reset the state so this happens again.

fish version: 3.0.2
OS: Ubuntu 19.10
$TERM: xterm-256color
Terminal emulator: gnome-terminal 3.34.0 (VTE 0.58.2)

I cannot reproduce this with sh -c 'env HOME=$(mktemp -d) fish'! But if I try to close the shell I spawned that way, I get a warning about active jobs, which might be a Clue.

Welcome to fish, the friendly interactive shell
mg@blynas /h/m/s/z/BTrees> 
There are still jobs active:

   PID  Command
 25573  $py $update_args >/dev/null 2>&1 &

A second attempt to exit will terminate them.
Use 'disown PID' to remove jobs from the list without terminating them.
mg@blynas /h/m/s/z/BTrees> 

(this also leaves my terminal in a noecho mode, which is annoying but unrelated)

It seems that something in my home directory (its sheer size? some config file somewhere?) is causing this, but I don't know what.

@mgedmin
Copy link
Author

@mgedmin mgedmin commented Nov 7, 2019

I've discovered a way of reproducing this:

  • rm -rf ~/.local/share/fish/
  • fish

Now fish is sitting there doing... something... with no output and no input, eating 100% of one CPU core. pstree shows it has no subproesses. strace shows it doing weird lstat calls on files in my home directory

...
getdents64(76, /* 14 entries */, 32768) = 400
brk(0x5592f9003000)                     = 0x5592f9003000
getdents64(76, /* 0 entries */, 32768)  = 0
lseek(76, 0, SEEK_SET)                  = 0
getdents64(76, /* 14 entries */, 32768) = 400
stat("PlayOnLinux's virtual drives/Subnautica/dosdevices/z:/sys/kernel/software_nodes/node0/0-0015/subsystem/devices/i2c-3/device/i2c-1/i2c-dev/i2c-1/subsystem/i2c-0/device/firmware_node/physical_node/iTCO_wdt/subsystem/devices/PNP0C14:00/firmware_node/subsystem/devices/device:2d/physical_node1/2-2.3/port/peer/device/1-2.3:1.0/driver/1-2:1.0/1-2-port1/peer/device/2-2.1:2.1/driver/2-2.1:2.0/net/enx482ae33b002a/subsystem/wlp0s20f3/phy80211/rfkill2/subsystem/rfkill0/device/leds/platform::mute/subsystem/phy0-led/device/subsystem/devices/0000:3a:00.0/usb4/subsystem/drivers/usb/1-2.3.3/1-2.3.3:1.0/1-2.3.3-port2/device/1-2.3.3.2:1.3/0003:17EF:A396.0019/input/input39/uevent", {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
stat("PlayOnLinux's virtual drives/Subnautica/dosdevices/z:/sys/kernel/software_nodes/node0/0-0015/subsystem/devices/i2c-3/device/i2c-1/i2c-dev/i2c-1/subsystem/i2c-0/device/firmware_node/physical_node/iTCO_wdt/subsystem/devices/PNP0C14:00/firmware_node/subsystem/devices/device:2d/physical_node1/2-2.3/port/peer/device/1-2.3:1.0/driver/1-2:1.0/1-2-port1/peer/device/2-2.1:2.1/driver/2-2.1:2.0/net/enx482ae33b002a/subsystem/wlp0s20f3/phy80211/rfkill2/subsystem/rfkill0/device/leds/platform::mute/subsystem/phy0-led/device/subsystem/devices/0000:3a:00.0/usb4/subsystem/drivers/usb/1-2.3.3/1-2.3.3:1.0/1-2.3.3-port2/device/1-2.3.3.2:1.3/0003:17EF:A396.0019/input/input39/capabilities", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/mg", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/mg/PlayOnLinux's virtual drives", {st_mode=S_IFLNK|0777, st_size=34, ...}) = 0
readlink("/home/mg/PlayOnLinux's virtual drives", "/home/mg/.PlayOnLinux//wineprefi"..., 4095) = 34
lstat("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/mg", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/mg/.PlayOnLinux", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
lstat("/home/mg/.PlayOnLinux/wineprefix", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
lstat("/home/mg/.PlayOnLinux/wineprefix/Subnautica", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
lstat("/home/mg/.PlayOnLinux/wineprefix/Subnautica/dosdevices", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
lstat("/home/mg/.PlayOnLinux/wineprefix/Subnautica/dosdevices/z:", {st_mode=S_IFLNK|0777, st_size=1, ...}) = 0
readlink("/home/mg/.PlayOnLinux/wineprefix/Subnautica/dosdevices/z:", "/", 4095) = 1
lstat("/sys", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
lstat("/sys/kernel", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/kernel/software_nodes", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/kernel/software_nodes/node0", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/kernel/software_nodes/node0/0-0015", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
readlink("/sys/kernel/software_nodes/node0/0-0015", "../../../devices/pci0000:00/0000"..., 4095) = 53
lstat("/sys/devices", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/devices/pci0000:00", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/devices/pci0000:00/0000:00:1f.4", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/devices/pci0000:00/0000:00:1f.4/i2c-0", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/devices/pci0000:00/0000:00:1f.4/i2c-0/0-0015", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/devices/pci0000:00/0000:00:1f.4/i2c-0/0-0015/subsystem", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
readlink("/sys/devices/pci0000:00/0000:00:1f.4/i2c-0/0-0015/subsystem", "../../../../../bus/i2c", 4095) = 22
lstat("/sys/bus", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/bus/i2c", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/bus/i2c/devices", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat("/sys/bus/i2c/devices/i2c-3", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
readlink("/sys/bus/i2c/devices/i2c-3", "../../../devices/pci0000:00/0000"..., 4095) = 46
...

I think it's getting confused when files have a : in the filename. on closer look that actually is a symlink to the root directory, I wonder if fish is getting into an infinite loop?

Note that ^C doesn't interrupt fish, I have to pkill it.

@mgedmin
Copy link
Author

@mgedmin mgedmin commented Nov 7, 2019

I tried rm -rf ~/.local/share/fish; strace -o /tmp/fish.trace fish and looked at the trace, and it looks like fish is trying to import my bash history? But it does that by opening and closing ~/.local/share/fish/fish_history once for every single line of history?

My ~/.bash_history has 25876 lines in it. fish managed to call open() on fish_history 13723 times in the first 16 seconds, before I killed it.

(My bashrc sets HISTSIZE=50000 and HISTFILESIZE=50000.)

@krobelus

This comment has been minimized.

@mgedmin

This comment has been minimized.

@krobelus

This comment has been minimized.

@krobelus
Copy link
Member

@krobelus krobelus commented Nov 7, 2019

A workaround is to create an empty ~/.local/share/fish/fish_history so fish will not import bash history, but we should definitely make this more efficient

@krobelus krobelus added the performance label Nov 7, 2019
krobelus added a commit to krobelus/fish-shell that referenced this issue Nov 7, 2019
@krobelus
Copy link
Member

@krobelus krobelus commented Nov 7, 2019

@mgedmin This commit might solve it: krobelus@speedup-bash-history-import, I was able to import 20k lines of history instantly.

@krobelus
Copy link
Member

@krobelus krobelus commented Nov 7, 2019

Fixed in master now. Thanks for your very useful report!

You can remove your ~/.local/share/fish/fish_history and start a version of fish with the fix to import your bash history.

@krobelus krobelus added this to the fish 3.1.0 milestone Nov 7, 2019
@mgedmin
Copy link
Author

@mgedmin mgedmin commented Nov 8, 2019

I can confirm that this fixes the entirety of the problem. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
performance
Projects
None yet
Development

No branches or pull requests

2 participants