Skip to content

Bash FFI lock - #760

Merged
HalFrgrd merged 7 commits into
masterfrom
bash_lock
Jul 2, 2026
Merged

HalFrgrd merged 7 commits into
masterfrom
bash_lock

Conversation

@HalFrgrd

@HalFrgrd HalFrgrd commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Stack trace from reddit user rvc2018:

 Module libgcc_s.so.1 from deb gcc-14-14.2.0-4ubuntu2~24.04.1.amd64
 Stack trace of thread 111739:
 #0  0x00007d7768c9eb2c __pthread_kill_implementation (libc.so.6 + 0x9eb2c)
 #1  0x00007d7768c4527e __GI_raise (libc.so.6 + 0x4527e)
 #2  0x00007d7768c2898f __GI_abort (libc.so.6 + 0x2898f)
 #3  0x00007d7768c297b6 __libc_message_impl (libc.so.6 + 0x297b6)
 #4  0x00007d7768ca8ff5 malloc_printerr (libc.so.6 + 0xa8ff5)
 #5  0x00007d7768ca9b7c unlink_chunk (libc.so.6 + 0xa9b7c)
 #6  0x00007d7768cac1d5 _int_malloc (libc.so.6 + 0xac1d5)
 #7  0x00007d7768cad714 __GI___libc_malloc (libc.so.6 + 0xad714)
 #8  0x00007d77674e0825 _ZN7flyline10bash_funcs26get_cached_shell_functions17hfd559c994049ed1aE (libflyline.so.1.2.2 + 0x2e0825)
 #9  0x00007d77674eca9a _ZN3std3sys9backtrace28__rust_begin_short_backtrace17h53ca149b4de0eaacE (libflyline.so.1.2.2 + 0x2eca9a)
 #10 0x00007d77674c4a71 _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hc83afb1daa2308a3E (libflyline.so.1.2.2 + 0x2c4a71)
 #11 0x00007d776764a860 _RNvNvMs0_NtNtNtCs3JBboNF8E1m_3std3sys6thread4unixNtB7_6Thread3new12thread_start (libflyline.so.1.2.2 + 0x44a860)
 #12 0x00007d7768c9caa4 start_thread (libc.so.6 + 0x9caa4)
 #13 0x00007d7768d29c6c __clone3 (libc.so.6 + 0x129c6c)

 Stack trace of thread 93017:
 #0  0x00007d7767351134 _RNvXs2_NtNtCs3BFokC4QLxY_4core3str5lossyNtB5_10Utf8ChunksNtNtNtNtB9_4iter6traits8iterator8Iterator4next (libflyline.so.1.2.2 + 0x151134)
 #1  0x00007d77672d2abc _RNvMNtCs8y6E41fb8tc_5alloc6stringNtB2_6String15from_utf8_lossy (libflyline.so.1.2.2 + 0xd2abc)
 #2  0x00007d77674117b4 _ZN7flyline3app11get_command17habdabd77e02ad1f3E (libflyline.so.1.2.2 + 0x2117b4)
 #3  0x00007d77674d609e _ZN7flyline16flyline_get_char17hab835fa189bea929E (libflyline.so.1.2.2 + 0x2d609e)
 #4  0x00005bf3513b2387 n/a (bash + 0x37387)
 #5  0x00005bf35148f66b n/a (bash + 0x11466b)
 #6  0x00005bf3513b6faf yyparse (bash + 0x3bfaf)
 #7  0x00005bf3513bac00 parse_command (bash + 0x3fc00)
 #8  0x00005bf3513badf9 read_command (bash + 0x3fdf9)
 #9  0x00005bf3513bb047 reader_loop (bash + 0x40047)
 #10 0x00005bf3513aeefb main (bash + 0x33efb)
 #11 0x00007d7768c2a1ca __libc_start_call_main (libc.so.6 + 0x2a1ca)
 #12 0x00007d7768c2a28b __libc_start_main_impl (libc.so.6 + 0x2a28b)
 #13 0x00005bf3513af385 _start (bash + 0x34385)
 ELF object binary architecture: AMD x86-64

The stack trace made me realize that we are not calling bash functions / reading bash owned data in a single threaded manner. I wanted to keep multi threading cache warming so I put in a lock on the ffi while flyline is running and made sure that we join threads before leaving flyline.

@HalFrgrd
HalFrgrd merged commit 25f725f into master Jul 2, 2026
@HalFrgrd
HalFrgrd deleted the bash_lock branch July 26, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant