Skip to content

[BUG]: v1.5.0: crash in background thread accessing bash internals (get_cached_shell_functions) #891

Closed

Description

@RVC2020

Describe the Bug

Hi, nice to see you back on the project. 🙂
I'm experiencing crashes with v1.5.0. This isn't happening in 1.3, 1.4.
With v1.5.0 across two different bash versions. I have captured two separate crash logs to show the bug is consistent.

Crash 1:

  • bash 5.2.21(1)-release
  • Happened during normal use
  • See fl1.log

Crash 2:

  • bash 5.3.0(1)-release
  • Happened immediately when enabling flyline from the terminal with enable -f libflyline.so.1.5.0 flyline
  • Before crashing, garbled escape codes appeared in the terminal: ^[[7;1R and ;1R — these look like cursor position query responses that flyline left on the terminal when it crashed mid-operation
  • The prompt also lost its newline formatting after the crash
  • I was able to reproduce this crash consistently
  • See fl2.log

Note on my prompt:
I have this in my PROMPT_COMMAND to add a newline after command output:

printf '\e[6n' >/dev/tty; IFS='[;' read -sdR _ row _ < /dev/tty; ((row==1)) || echo

This sends a cursor position query (\e[6n) to the terminal. It is possible this interacts badly with flyline's own cursor position queries when flyline is initializing, and might be related to the garbled escape codes seen in Crash 2.

Flyline's background cache warming thread appears to be colliding with the main thread on shared bash state. Both crashes point to the same internal function (get_cached_shell_functions) but hitting slightly different points each time. Race condition?

fl1.log

fl2.log

Environment & Version Information

flyline 1.5.0
git hash: d437a50
build mode: release
build datetime: 2026-08-03T22:28:40Z
build target: x86_64-unknown-linux-gnu
rustc version: rustc 1.97.1 (8bab26f4f 2026-07-14)

Running in: Bash 5.3.0(1)-release
shell: /bin/bash

Running in: xterm-256color
program: WezTerm
program version: 20240203-110809-5046fc22
locale: en_US.UTF-8 (LC_ALL: unknown, LC_CTYPE: unknown)

Running in: Linux Mint 22.3 (kernel 6.8.0-137-generic x86_64)
system linker: GNU ld (GNU Binutils for Ubuntu) 2.42
dynamic linker: ldd (Ubuntu GLIBC 2.39-0ubuntu8.8) 2.39

Running on: AMD Ryzen 5 5500 (12 cores)

Running in: a simulation

Debug Logs (Optional / If Necessary)

Click to expand logs
<paste logs here>

Steps to Reproduce

  1. Enable flyline in bash 5.2.21: enable -f libflyline.so.1.5.0 flyline

  2. Use the shell normally (tab completion, general commands)

  3. Crash happens during normal use, not always immediately

  4. Have this in PROMPT_COMMAND:
    printf '\e[6n' >/dev/tty; IFS='[;' read -sdR _ row _ < /dev/tty; ((row==1)) || echo

  5. Start bash 5.3.0

  6. Enable flyline: enable -f libflyline.so.1.5.0 flyline

  7. Crash happens immediately with garbled escape codes
    visible in the terminal: ^[[7;1R and ;1R

Activity

  1. added
    bug
    on Aug 8, 2026
  2. HalFrgrd commented on Aug 9, 2026

    @HalFrgrd
    Owner

    Thanks for the detailed issue! I wasnt able to reproduce it locally but using your crash logs I may have found the problem. I've made #895.

    With the next release, could you please test if flyline still crashes for you? If it does, could you confirm if it still crashes when you remove your PROMPT_COMMAND? e.g. start bash with bash --norc then run enable -f libflyline.so flyline.

    I think the reason you see garbled escape codes is that another flyline thread is blocked on get_cursor_position . in get_cursor_position, flyline sends \e6n , then crashes before it reads the response and the response is printed to the terminal because flyline isnt around to read it. I doubt your PROMPT_COMMAND will interact with flyline since they run one after another.

  3. RVC2020 commented on Aug 9, 2026

    @RVC2020
    Author

    With the next release, could you please test if flyline still crashes for you? If it does, could you confirm if it still crashes when you remove your PROMPT_COMMAND? e.g. start bash with bash --norc then run enable -f libflyline.so flyline.

    Sure, if you'd like me to compile and test PR #895 so you don't have to make a new release, I can do that. I still have the Rust toolchain in Docker from the previous bug I reported. Just let me know.

  4. HalFrgrd commented on Aug 9, 2026

    @HalFrgrd
    Owner

    Thanks, I just saw this. I've just released v1.6.0. let me know if the bug persists!

  5. RVC2020 commented on Aug 11, 2026

    @RVC2020
    Author

    Good news - The latest releases seem to have fixed get_cached_shell_functions bug. (I am on v1.6.2).
    Bad news - I got a similar crash because of synthesize_from_help and get_cwd hitting the same class of problem.

    fl-1.6.2-crash.log

    At this point, I think we should officially list my CPU as a project contributor; it finds bugs faster than any test suite. 😀

    For the record, I think you were right about PROMPT_COMMAND, it does not seem to interfere with Flyline. I was
    wrong to suggest it earlier.

    I propose renaming this thread and turning it into a tracking issue for this class of bugs. So I can keep posting new crash logs
    here instead of opening a new issue each time.

  6. HalFrgrd commented on Aug 11, 2026

    @HalFrgrd
    Owner

    😄 there is something about your setup that catches every race condition! I have a very similar setup so it puzzles me why I dont see them.

    Thanks for the crash log. I've figure out how to insert a shim that checks every thread that wants to access the bash allocator is the main thread. This helps me detect the problem your experiencing locally.

    It's quite interesting. I try and make flyline use a separate allocator because bash's allocator isn't thread safe. But what your crash log shows is that during thread startup / exit, it calls some glibc function __cxa_thread_atexit_impl which then tries to call malloc which resolves to bash's non thread safe allocator. Flyline can't control what glibc calls!

    I will need to investigate a solution when I have more time. Possibly starting the threads all at once at startup and then reusing them.

  7. RVC2020 commented on Aug 11, 2026

    @RVC2020
    Author

    I noticed on one of your bug reports that you were using a Ryzen 7 5700G on Ubuntu. So yeah, fun puzzle.
    My best guess is it has something to do with my Docker stack. I have several containers with active network I/O, plus a WireGuard VPN handling regular traffic. Wireguard might be particularly disruptive for the kernel scheduler since it runs in kernel space, generating constant interrupts.

    Take your time. This problem seems anything but trivial, and Flyline has enough features to keep us users busy for a while.

  8. added a commit that references this issue on Aug 14, 2026
  9. HalFrgrd commented on Aug 14, 2026

    @HalFrgrd
    Owner

    Ive decided to stop using threads. I couldnt find a convenient way to use them without leading to concurrent bash allocator access. I made fork of bash that crashes when it detects concurrent bash allocator access so that I could recreate your bugs. So hopefully this fixes this entire class of bug! Ofc, please let me know if you do experience any more. I imagine other people tried flyline, it crashed and then they never tried it again. And thanks for your helpful stacktraces!

    If you could test the latest flyline master build (you download the CI build from https://github.com/HalFrgrd/flyline/actions/runs/31841804067 , look for built-flyline-library) I would be very grateful. I'll probably release a new version this weekend.

  10. RVC2020 commented on Aug 15, 2026

    @RVC2020
    Author

    Ok, I'll test it:

    flyline 1.6.2
    git hash: unknown
    build mode: release
    build datetime: 2026-08-14T21:20:48Z
    build target: x86_64-unknown-linux-gnu
    rustc version: rustc 1.94.0 (4a4ef493e 2026-03-02)
    
    Running in: Bash 5.3.15(1)-release
    shell: /bin/bash
    
    Running in: xterm-256color (WezTerm)
    multiplexer: none
    device attributes raw: >1;277;0
    device attributes version: 20220408
    program: WezTerm
    program version: 20240203-110809-5046fc22
    locale: en_US.UTF-8 (LC_ALL: unknown, LC_CTYPE: unknown)
    
    Running in: Linux Mint 22.3 (kernel 6.8.0-137-generic x86_64)
    system linker: GNU ld (GNU Binutils for Ubuntu) 2.42
    dynamic linker: ldd (Ubuntu GLIBC 2.39-0ubuntu8.8) 2.39
    
    Running on: AMD Ryzen 5 5500 (12 cores)
    
    Running in: a simulation
    

    I imagine other people tried flyline, it crashed and then they never tried it again.

    Don't be too hard on yourself. You're not a billion-dollars company with hundreds of beta testers. When I first saw you announcing Flyline on Reddit, I was expecting far more bugs and far fewer features.

  11. todated commented on Aug 19, 2026

    @todated

    since 1.7.0 i'm no longer having crashes like this;
    (this had been a blocker for me across the previous few versions that i tried)
    glad to be able to now use flyline as my default/daily driver;
    thank you;

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions