Skip to content

Race condition in path_emit_config_directory_messages #10813

@septatrix

Description

@septatrix
  • Fish version: 3.7.1
  • Kernel version: Linux archlinux 6.11.5-arch1-1 Need a history built-in #1 SMP PREEMPT_DYNAMIC Tue, 22 Oct 2024 18:31:38 +0000 x86_64 GNU/Linux
  • Terminal: xterm-256color

If two fish instances are started simultaneously and the fish directories (.config/fish etc) do not exist there is a race condition where both shells try to create the directories as part of https://github.com/fish-shell/fish-shell/blob/3.7.1/src/path.cpp#L344. Often one shell will get the EEXIST error code returned and assume an error occurred instead of ignoring it. This causes the erroneous printing of the warning that the directories could not have been created.

root@archlinux ~# set --erase --universal _FISH_WARNED
root@archlinux ~ [4]# rm -r ~/foobar
root@archlinux ~# XDG_DATA_HOME=$PWD/foobar fish & XDG_DATA_HOME=$PWD/foobar fish
error: can not save history
warning-path: Unable to locate data directory derived from $XDG_DATA_HOME: '/root/foobar/fish'.
warning-path: The error was 'File exists'.
warning-path: Please set $XDG_DATA_HOME to a directory where you have write access.

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
root@archlinux ~#

In my case this always happens when booting VMs for testing where fish is spawned on tty1 and hvc0 (normal TTY and QEMU hypervisor console) after booting

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions