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

[BUG] rofi crashes with SIGSEGV #1966

Closed
2 tasks done
christian-heusel opened this issue Mar 19, 2024 · 40 comments
Closed
2 tasks done

[BUG] rofi crashes with SIGSEGV #1966

christian-heusel opened this issue Mar 19, 2024 · 40 comments
Labels

Comments

@christian-heusel
Copy link

Rofi version (rofi -v)

Version: 1.7.5

Configuration

https://gist.github.com/christian-heusel/c27b5f9bcfdc4f223c4c420ab7755348

Theme

https://gist.github.com/christian-heusel/a42f58d3dee964958ddef4480020d66f

Timing report

No response

Launch command

rofi -lines "4" -fake-transparency -show run

Step to reproduce

A bit unclear on how to reproduce exactly, crashes from time to time only.

Expected behavior

Rofi does not crash

Actual behavior

Rofi crashes with SIGSEGV.

Additional information

Here is the trace from the crash:

(gdb) bt full
#0  sljit_remove_free_block (free_block=0x7b3468fc5ff0)
    at src/sljit/allocator_src/sljitExecAllocatorCore.c:137
#1  sljit_free_exec (ptr=0x7b3468fc5fc0)
    at src/sljit/allocator_src/sljitExecAllocatorCore.c:281
        header = 0x7b3468fc5ff0
        free_block = 0x7b3468fb6040
#2  0x00007b3469db22c7 in pcre2_jit_compile_8
    (code=0x57b44338fec0, options=options@entry=1)
    at src/pcre2_jit_compile.c:14861
        ptr = <optimized out>
        re = 0x57b44338fec0
        functions = 0x0
        executable_allocator_is_working = -1
#3  0x00007b346a490245 in enable_jit_with_match_options
    (match_options=0, match_info=0x7b3434000b70) at ../glib/glib/gregex.c:934
        retval = <optimized out>
        old_jit_options = <optimized out>
        new_jit_options = 1
        retval = <optimized out>
        old_jit_options = <optimized out>
        new_jit_options = <optimized out>
        __func__ = {<optimized out> <repeats 30 times>}
        _g_boolean_var_12 = <optimized out>
#4  g_match_info_next
    (match_info=match_info@entry=0x7b3434000b70, error=error@entry=0x0)
    at ../glib/glib/gregex.c:1117
        jit_status = <optimized out>
        prev_match_start = -1
        prev_match_end = -1
        opts = 0
        __func__ = "g_match_info_next"
#5  0x00007b346a4904a9 in g_regex_match_full
    (regex=<optimized out>, string=string@entry=0x57b443569430 "knewstuff-dialog", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
        info = 0x7b3434000b70
        match_ok = <optimized out>
        __func__ = "g_regex_match_full"
#6  0x00007b346a4905af in g_regex_match
    (regex=<optimized out>, string=string@entry=0x57b443569430 "knewstuff-dialog", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#7  0x000057b44306c020 in helper_token_match
    (tokens=<optimized out>, input=0x57b443569430 "knewstuff-dialog")
    at source/helper.c:531
        j = <optimized out>
        match = <optimized out>
#8  0x000057b443066952 in filter_elements
    (ts=0x7fffe8de6f10, user_data=<optimized out>) at source/view.c:697
        match = <optimized out>
        i = 2152
        t = 0x7fffe8de6f10
#9  0x00007b346a4a9523 in g_thread_pool_thread_proxy (data=<optimized out>)
    at ../glib/glib/gthreadpool.c:350
        task = 0x7fffe8de6f10
        pool = 0x57b4433aee90
#10 0x00007b346a4a6a45 in g_thread_proxy (data=0x7b3460001090)
    at ../glib/glib/gthread.c:831
        thread = 0x7b3460001090
        __func__ = "g_thread_proxy"
#11 0x00007b3469f0355a in start_thread (arg=<optimized out>)
    at pthread_create.c:447
        ret = <optimized out>
        pd = <optimized out>
        out = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {135464877033152, -6406633191085060344, -120, 0, 135465028024912, 135464868642816, 5872604516727508744, 5872626766882524936}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#12 0x00007b3469f80a3c in clone3 ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Using wayland display server protocol

  • No, I don't use the wayland display server protocol

I've checked if the issue exists in the latest stable release

  • Yes, I have checked the problem exists in the latest stable version
@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Mar 19, 2024

Interesting, looks like a crash in glib->regex ..
What version of glib?

can you do a thread apply all bt (see man rofi-debugging).

@DaveDavenport
Copy link
Collaborator

Another test does it crash with rofi -threads 1 -show run?

@christian-heusel
Copy link
Author

christian-heusel commented Mar 19, 2024

What version of glib?

pacman -Qi glib2 -> 2.78.4-1

Its the most recent version on Arch Linux.

Another test does it crash with rofi -threads 1 -show run?

I couldnt get it to reproduce with that, atleast not for the moment. As I said earlier I didnt find a reproducer so far, so its a bit hard to tell if that is because of the changed option.

can you do a thread apply all bt (see man rofi-debugging).

The backtrace is obtained via coredumpctl see the full trace below.

Click to see trace
(gdb) thread apply all bt

Thread 14 (Thread 0x7f78dfe006c0 (LWP 112083)):
#0  futex_wait (private=0, expected=2, futex_word=0x7f78f2bfe060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>, private=0) at lowlevellock.c:49
#2  0x00007f78f2d049b2 in lll_mutex_lock_optimized (mutex=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x00007f78f2b7e031 in sljit_malloc_exec (size=<optimized out>) at src/sljit/allocator_src/sljitExecAllocatorCore.c:168
#5  0x00007f78f2bb02ba in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14858
#6  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x7f78b4000b70) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0x7f78b4000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e9a0710 "latexpand", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e9a0710 "latexpand", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#10 0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e9a0710 "latexpand") at source/helper.c:531
#11 0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0da0, user_data=<optimized out>) at source/view.c:697
#12 0x00007f78f32a7523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#13 0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec0013b0) at ../glib/glib/gthread.c:831
#14 0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 13 (Thread 0x7f78e8c006c0 (LWP 112082)):
#0  futex_wait (private=0, expected=2, futex_word=0x7f78f2bfe060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>, private=0) at lowlevellock.c:49
#2  0x00007f78f2d049b2 in lll_mutex_lock_optimized (mutex=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x00007f78f2b7e031 in sljit_malloc_exec (size=<optimized out>) at src/sljit/allocator_src/sljitExecAllocatorCore.c:168
#5  0x00007f78f2bb02ba in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14858
#6  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x7f78bc000b70) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0x7f78bc000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e9a1f90 "mktexfmt", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e9a1f90 "mktexfmt", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#10 0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e9a1f90 "mktexfmt") at source/helper.c:531
#11 0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0de8, user_data=<optimized out>) at source/view.c:697
#12 0x00007f78f32a7523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#13 0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec001210) at ../glib/glib/gthread.c:831
#14 0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 12 (Thread 0x7f78dea006c0 (LWP 112085)):
#0  futex_wait (private=0, expected=2, futex_word=0x7f78f2bfe060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>, private=0) at lowlevellock.c:49
#2  0x00007f78f2d049b2 in lll_mutex_lock_optimized (mutex=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x00007f78f2b7e031 in sljit_malloc_exec (size=<optimized out>) at src/sljit/allocator_src/sljitExecAllocatorCore.c:168
#5  0x00007f78f2bb02ba in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14858
#6  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x7f78a8000b70) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0x7f78a8000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e98f0f0 "slabtop", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e98f0f0 "slabtop", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#10 0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e98f0f0 "slabtop") at source/helper.c:531
#11 0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0ec0, user_data=<optimized out>) at source/view.c:697
#12 0x00007f78f32a7523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#13 0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec0016f0) at ../glib/glib/gthread.c:831
#14 0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 11 (Thread 0x7f78e96006c0 (LWP 112081)):
#0  futex_wait (private=0, expected=2, futex_word=0x7f78f2bfe060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>, private=0) at lowlevellock.c:49
#2  0x00007f78f2d049b2 in lll_mutex_lock_optimized (mutex=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x00007f78f2b7e031 in sljit_malloc_exec (size=<optimized out>) at src/sljit/allocator_src/sljitExecAllocatorCore.c:168
#5  0x00007f78f2bb02ba in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14858
#6  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x7f78c0000b70) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0x7f78c0000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e98ed30 "ppmtoyuv", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e98ed30 "ppmtoyuv", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#10 0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e98ed30 "ppmtoyuv") at source/helper.c:531
#11 0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0e78, user_data=<optimized out>) at source/view.c:697
#12 0x00007f78f32a7523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#13 0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec001070) at ../glib/glib/gthread.c:831
#14 0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 10 (Thread 0x7f78f1e006c0 (LWP 112074)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f78f32cc337 in g_cond_wait (cond=0x55af5e7edbd8, mutex=0x55af5e7edbd0) at ../glib/glib/gthread-posix.c:1552
#2  0x00007f78f323e1b4 in g_async_queue_pop_intern_unlocked (queue=0x55af5e7edbd0, wait=1, end_time=-1) at ../glib/glib/gasyncqueue.c:425
#3  0x00007f78f32a6ace in g_thread_pool_spawn_thread (data=<optimized out>) at ../glib/glib/gthreadpool.c:311
#4  0x00007f78f32a4a45 in g_thread_proxy (data=0x55af5e7bb570) at ../glib/glib/gthread.c:831
#5  0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#6  0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 9 (Thread 0x7f78ea0006c0 (LWP 112080)):
#0  futex_wait (private=0, expected=2, futex_word=0x7f78f2bfe060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>, private=0) at lowlevellock.c:49
#2  0x00007f78f2d049b2 in lll_mutex_lock_optimized (mutex=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x00007f78f2b7e031 in sljit_malloc_exec (size=<optimized out>) at src/sljit/allocator_src/sljitExecAllocatorCore.c:168
#5  0x00007f78f2bb02ba in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14858
#6  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x7f78c8000b70) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0x7f78c8000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e98f690 "gsnd", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e98f690 "gsnd", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#10 0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e98f690 "gsnd") at source/helper.c:531
#11 0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0d58, user_data=<optimized out>) at source/view.c:697
#12 0x00007f78f32a7523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#13 0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec000ed0) at ../glib/glib/gthread.c:831
#14 0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 8 (Thread 0x7f78eaa006c0 (LWP 112079)):
#0  futex_wait (private=0, expected=2, futex_word=0x7f78f2bfe060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>, private=0) at lowlevellock.c:49
#2  0x00007f78f2d049b2 in lll_mutex_lock_optimized (mutex=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x00007f78f2b7e031 in sljit_malloc_exec (size=<optimized out>) at src/sljit/allocator_src/sljitExecAllocatorCore.c:168
#5  0x00007f78f2bb02ba in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14858
#6  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x7f78cc000b70) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0x7f78cc000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e99e640 "pamexec", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e99e640 "pamexec", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#10 0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e99e640 "pamexec") at source/helper.c:531
#11 0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0e30, user_data=<optimized out>) at source/view.c:697
#12 0x00007f78f32a7523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#13 0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec000d30) at ../glib/glib/gthread.c:831
#14 0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 7 (Thread 0x7f78eb4006c0 (LWP 112078)):
#0  futex_wait (private=0, expected=2, futex_word=0x7f78f2bfe060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>, private=0) at lowlevellock.c:49
#2  0x00007f78f2d049b2 in lll_mutex_lock_optimized (mutex=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x00007f78f2b7e031 in sljit_malloc_exec (size=<optimized out>) at src/sljit/allocator_src/sljitExecAllocatorCore.c:168
#5  0x00007f78f2bb02ba in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14858
#6  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x7f78d4000b70) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0x7f78d4000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e9a84d0 "enchant-lsmod-2", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e9a84d0 "enchant-lsmod-2", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#10 0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e9a84d0 "enchant-lsmod-2") at source/helper.c:531
#11 0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0d10, user_data=<optimized out>) at source/view.c:697
#12 0x00007f78f32a7523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#13 0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec000b90) at ../glib/glib/gthread.c:831
#14 0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 6 (Thread 0x7f78df4006c0 (LWP 112084)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f78f32cc20b in g_mutex_lock_slowpath (mutex=0x55af5e7afc20) at ../glib/glib/gthread-posix.c:1465
#2  0x00007f78f32a73e9 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:333
#3  0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec001550) at ../glib/glib/gthread.c:831
#4  0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#5  0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 5 (Thread 0x7f78f14006c0 (LWP 112075)):
#0  0x00007f78f2d710bf in __GI___poll (fds=0x55af5e7f0c60, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f78f32d12f6 in g_main_context_poll_unlocked (priority=2147483647, n_fds=1, fds=0x55af5e7f0c60, timeout=<optimized out>, context=0x55af5e7f0a30) at ../glib/glib/gmain.c:4653
#2  g_main_context_iterate_unlocked.isra.0 (context=context@entry=0x55af5e7f0a30, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/glib/gmain.c:4344
#3  0x00007f78f3271162 in g_main_context_iteration (context=0x55af5e7f0a30, may_block=may_block@entry=1) at ../glib/glib/gmain.c:4414
#4  0x00007f78f32711b2 in glib_worker_main (data=<optimized out>) at ../glib/glib/gmain.c:6574
#5  0x00007f78f32a4a45 in g_thread_proxy (data=0x55af5e7b8700) at ../glib/glib/gthread.c:831
#6  0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#7  0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 4 (Thread 0x7f78ebe006c0 (LWP 112077)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f78f32cc337 in g_cond_wait (cond=0x55af5e803e78, mutex=0x55af5e803e70) at ../glib/glib/gthread-posix.c:1552
#2  0x00007f78f323e1b4 in g_async_queue_pop_intern_unlocked (queue=0x55af5e803e70, wait=1, end_time=-1) at ../glib/glib/gasyncqueue.c:425
#3  0x00007f78f323e21c in g_async_queue_pop (queue=queue@entry=0x55af5e803e70) at ../glib/glib/gasyncqueue.c:459
#4  0x00007f78f2b22c48 in fc_thread_func (data=0x55af5e803e70) at ../pango/pango/pangofc-fontmap.c:959
#5  0x00007f78f32a4a45 in g_thread_proxy (data=0x55af5e8f7800) at ../glib/glib/gthread.c:831
#6  0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#7  0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 3 (Thread 0x7f78f2356d00 (LWP 112073)):
#0  futex_wait (private=0, expected=2, futex_word=0x7f78f2bfe060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>, private=0) at lowlevellock.c:49
#2  0x00007f78f2d049b2 in lll_mutex_lock_optimized (mutex=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x7f78f2bfe060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x00007f78f2b7e1fd in sljit_free_exec (ptr=0x7f78f1ea6010) at src/sljit/allocator_src/sljitExecAllocatorCore.c:254
#5  0x00007f78f2bb02c7 in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14861
#6  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x55af5e915ee0) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0x55af5e915ee0, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e90be20 "terminator", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e90be20 "terminator", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#10 0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e90be20 "terminator") at source/helper.c:531
#11 0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0c80, user_data=<optimized out>) at source/view.c:697
#12 0x000055af5dd23a36 in rofi_view_call_thread (user_data=0x0, data=0x7ffdf8ee0c80) at source/view.c:690
#13 rofi_view_refilter_real (state=state@entry=0x55af5e91add0) at source/view.c:1222
#14 0x000055af5dd23cfd in rofi_view_refilter_real (state=0x55af5e91add0) at source/view.c:1307
#15 0x000055af5dd23d9a in rofi_view_maybe_update (state=0x55af5e91add0) at source/view.c:1730
#16 0x000055af5dd38aa9 in main_loop_x11_event_handler_view (event=0x55af5e9102a0) at source/xcb.c:1285
#17 main_loop_x11_event_handler (ev=ev@entry=0x55af5e7bbb40, user_data=user_data@entry=0x0) at source/xcb.c:1331
#18 0x000055af5dd47f93 in _g_water_xcb_source_dispatch (source=<optimized out>, callback=0x55af5dd389e0 <main_loop_x11_event_handler>, user_data=0x0) at subprojects/libgwater/xcb/libgwater-xcb.c:97
#19 0x00007f78f3272f69 in g_main_dispatch (context=0x55af5e7abd50) at ../glib/glib/gmain.c:3476
#20 0x00007f78f32d13a7 in g_main_context_dispatch_unlocked (context=0x55af5e7abd50) at ../glib/glib/gmain.c:4284
#21 g_main_context_iterate_unlocked.isra.0 (context=0x55af5e7abd50, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/glib/gmain.c:4349
#22 0x00007f78f3273b97 in g_main_loop_run (loop=0x55af5e7b9870) at ../glib/glib/gmain.c:4551
#23 0x000055af5dd103bb in main (argc=<optimized out>, argv=0x7ffdf8ee13b8) at source/rofi.c:1137

Thread 2 (Thread 0x7f78f0a006c0 (LWP 112076)):
#0  0x00007f78f2d710bf in __GI___poll (fds=0x7f78e0000b90, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f78f32d12f6 in g_main_context_poll_unlocked (priority=2147483647, n_fds=2, fds=0x7f78e0000b90, timeout=<optimized out>, context=0x55af5e7fe1e0) at ../glib/glib/gmain.c:4653
#2  g_main_context_iterate_unlocked.isra.0 (context=0x55af5e7fe1e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/glib/gmain.c:4344
#3  0x00007f78f3273b97 in g_main_loop_run (loop=0x55af5e7fe310) at ../glib/glib/gmain.c:4551
#4  0x00007f78f34e019c in gdbus_shared_thread_func (user_data=0x55af5e7f48f0) at ../glib/gio/gdbusprivate.c:284
#5  0x00007f78f32a4a45 in g_thread_proxy (data=0x55af5e7fe330) at ../glib/glib/gthread.c:831
#6  0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#7  0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 1 (Thread 0x7f78de0006c0 (LWP 112086)):
#0  sljit_remove_free_block (free_block=0x7f78f1eb5ff0) at src/sljit/allocator_src/sljitExecAllocatorCore.c:137
#1  sljit_free_exec (ptr=0x7f78f1eb5fc0) at src/sljit/allocator_src/sljitExecAllocatorCore.c:281
#2  0x00007f78f2bb02c7 in pcre2_jit_compile_8 (code=0x55af5e9150c0, options=options@entry=1) at src/pcre2_jit_compile.c:14861
#3  0x00007f78f328e245 in enable_jit_with_match_options (match_options=0, match_info=0x7f78a4000b70) at ../glib/glib/gregex.c:934
#4  g_match_info_next (match_info=match_info@entry=0x7f78a4000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#5  0x00007f78f328e4a9 in g_regex_match_full (regex=<optimized out>, string=string@entry=0x55af5e991e10 "checkbandwidth", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#6  0x00007f78f328e5af in g_regex_match (regex=<optimized out>, string=string@entry=0x55af5e991e10 "checkbandwidth", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2204
#7  0x000055af5dd1d020 in helper_token_match (tokens=<optimized out>, input=0x55af5e991e10 "checkbandwidth") at source/helper.c:531
#8  0x000055af5dd17952 in filter_elements (ts=0x7ffdf8ee0cc8, user_data=<optimized out>) at source/view.c:697
#9  0x00007f78f32a7523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#10 0x00007f78f32a4a45 in g_thread_proxy (data=0x7f78ec001890) at ../glib/glib/gthread.c:831
#11 0x00007f78f2d0155a in start_thread (arg=<optimized out>) at pthread_create.c:447
#12 0x00007f78f2d7ea3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

@DaveDavenport
Copy link
Collaborator

thanks.

@ravomavain
Copy link

I have the same random crash on archlinux (with lbonn wayland fork) since a few days, it correspond to the following update :

[2024-03-14T20:57:51+0100] [ALPM] upgraded pcre2 (10.42-2 -> 10.43-1)

I can reproduce the crash by retrying multiple times with lots of thread and a filter :

while sleep 0.1;do timeout 0.1 rofi -threads 100000 -show run -filter a; done

I can't reproduce anymore if I downgrade to pcre2 10.42 or if I use -threads 1

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Mar 20, 2024

Was kinda afraid of that. :(

Thanks for testing it was the pcre update.

@DaveDavenport
Copy link
Collaborator

Can you try this patch to see if it helps?

diff --git a/source/view.c b/source/view.c
index aac8c22e..8a9ea5cd 100644
--- a/source/view.c
+++ b/source/view.c
@@ -736,6 +736,7 @@ typedef struct _thread_state_view {
   const char *pattern;
   /** Length of pattern. */
   glong plen;
+  rofi_int_matcher **tokens;
 } thread_state_view;
 /**
  * @param data A thread_state object.
@@ -752,7 +753,7 @@ static void filter_elements(thread_state *ts,
                             G_GNUC_UNUSED gpointer user_data) {
   thread_state_view *t = (thread_state_view *)ts;
   for (unsigned int i = t->start; i < t->stop; i++) {
-    int match = mode_token_match(t->state->sw, t->state->tokens, i);
+    int match = mode_token_match(t->state->sw, t->tokens, i);
     // If each token was matched, add it to list.
     if (match) {
       t->state->line_map[t->start + t->count] = i;
@@ -1450,6 +1451,7 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
     unsigned int count = nt;
     unsigned int steps = (state->num_lines + nt) / nt;
     for (unsigned int i = 0; i < nt; i++) {
+      states[i].tokens = helper_tokenize(pattern, config.case_sensitive);
       states[i].state = state;
       states[i].start = i * steps;
       states[i].stop = MIN(state->num_lines, (i + 1) * steps);
@@ -1478,6 +1480,12 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
     }
     g_cond_clear(&cond);
     g_mutex_clear(&mutex);
+    for (unsigned int i = 0; i < nt; i++) {
+      if (states[i].tokens) {
+        helper_tokenize_free(states[i].tokens);
+        states[i].tokens = NULL;
+      }
+    }
     for (unsigned int i = 0; i < nt; i++) {
       if (j != states[i].start) {
         memmove(&(state->line_map[j]), &(state->line_map[states[i].start]),

@DaveDavenport
Copy link
Collaborator

@lbonn I suspect this will be reported to your fork too.

@christian-heusel
Copy link
Author

I have built the package with the patch and will see if I get any more segfaults in the next days 🤔

@DaveDavenport
Copy link
Collaborator

I have built the package with the patch and will see if I get any more segfaults in the next days 🤔

Thanks.

@christian-heusel
Copy link
Author

christian-heusel commented Mar 21, 2024

Can you try this patch to see if it helps?

It seems like the patched version also crashes for me 🤔

Click to see trace
(gdb) bt full
#0  sljit_remove_free_block (free_block=<optimized out>) at src/sljit/allocator_src/sljitExecAllocatorCore.c:140
#1  sljit_free_exec (ptr=0x7fcd65829fc0) at src/sljit/allocator_src/sljitExecAllocatorCore.c:281
        header = <optimized out>
        free_block = 0x7fcd6581a040
#2  0x00007fcd665a12c7 in pcre2_jit_compile_8 (code=0x5631fc4ad0d0, options=options@entry=1) at src/pcre2_jit_compile.c:14861
        ptr = <optimized out>
        re = 0x5631fc4ad0d0
        functions = 0x0
        executable_allocator_is_working = -1
#3  0x00007fcd66c7bb05 in enable_jit_with_match_options (match_options=0, match_info=0x7fcd30000b70) at ../glib/glib/gregex.c:933
        retval = <optimized out>
        old_jit_options = <optimized out>
        new_jit_options = 1
        retval = <optimized out>
        old_jit_options = <optimized out>
        new_jit_options = <optimized out>
        __func__ = {<optimized out> <repeats 30 times>}
        _g_boolean_var_12 = <optimized out>
#4  g_match_info_next (match_info=match_info@entry=0x7fcd30000b70, error=error@entry=0x0) at ../glib/glib/gregex.c:1116
        jit_status = <optimized out>
        prev_match_start = -1
        prev_match_end = -1
        opts = 0
        __func__ = "g_match_info_next"
#5  0x00007fcd66c7bd69 in g_regex_match_full
    (regex=<optimized out>, string=string@entry=0x5631fc4e1cd0 "gssdp-device-sniffer", string_len=string_len@entry=-1, start_position=start_position@entry=0, match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0, error=0x0) at ../glib/glib/gregex.c:2294
        info = 0x7fcd30000b70
        match_ok = <optimized out>
        __func__ = "g_regex_match_full"
#6  0x00007fcd66c7be6f in g_regex_match
    (regex=<optimized out>, string=string@entry=0x5631fc4e1cd0 "gssdp-device-sniffer", match_options=match_options@entry=G_REGEX_MATCH_DEFAULT, match_info=match_info@entry=0x0) at ../glib/glib/gregex.c:2203
#7  0x00005631fa4ae010 in helper_token_match (tokens=<optimized out>, input=0x5631fc4e1cd0 "gssdp-device-sniffer") at source/helper.c:531
        j = <optimized out>
        match = <optimized out>
#8  0x00005631fa4a894f in filter_elements (ts=0x7ffcf2e35e10, user_data=<optimized out>) at source/view.c:698
        match = <optimized out>
        i = 1533
        t = 0x7ffcf2e35e10
#9  0x00007fcd66c97bc3 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:336
        task = 0x7ffcf2e35e10
        pool = 0x5631fc37fed0
#10 0x00007fcd66c92065 in g_thread_proxy (data=0x7fcd60001210) at ../glib/glib/gthread.c:835
        thread = 0x7fcd60001210
        __func__ = "g_thread_proxy"
#11 0x00007fcd666f255a in start_thread (arg=<optimized out>) at pthread_create.c:447
        ret = <optimized out>
        pd = <optimized out>
        out = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140519852213952, 8432720566785797901, -120, 0, 140520147909200, 140519843823616, -8458414229431128307, -8458386327568912627}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#12 0x00007fcd6676fa3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

@DaveDavenport
Copy link
Collaborator

Thanks for testing.

@DaveDavenport
Copy link
Collaborator

I need to setup a system to debug this myself:

diff --git a/source/view.c b/source/view.c
index aac8c22e..28849cb3 100644
--- a/source/view.c
+++ b/source/view.c
@@ -655,10 +655,6 @@ void rofi_view_set_selected_line(RofiViewState *state,
 }
 
 void rofi_view_free(RofiViewState *state) {
-  if (state->tokens) {
-    helper_tokenize_free(state->tokens);
-    state->tokens = NULL;
-  }
   // Do this here?
   // Wait for final release?
   widget_free(WIDGET(state->main_window));
@@ -751,8 +747,12 @@ static void rofi_view_call_thread(gpointer data, gpointer user_data) {
 static void filter_elements(thread_state *ts,
                             G_GNUC_UNUSED gpointer user_data) {
   thread_state_view *t = (thread_state_view *)ts;
+
+  /** Regexs used for matching */
+  rofi_int_matcher **tokens =
+      helper_tokenize(t->pattern, config.case_sensitive);
   for (unsigned int i = t->start; i < t->stop; i++) {
-    int match = mode_token_match(t->state->sw, t->state->tokens, i);
+    int match = mode_token_match(t->state->sw, tokens, i);
     // If each token was matched, add it to list.
     if (match) {
       t->state->line_map[t->start + t->count] = i;
@@ -775,6 +775,8 @@ static void filter_elements(thread_state *ts,
       t->count++;
     }
   }
+
+  helper_tokenize_free(tokens);
   if (t->acount != NULL) {
     g_mutex_lock(t->mutex);
     (*(t->acount))--;
@@ -1450,6 +1452,8 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
     unsigned int count = nt;
     unsigned int steps = (state->num_lines + nt) / nt;
     for (unsigned int i = 0; i < nt; i++) {
+      //      states[i].tokens = helper_tokenize(pattern,
+      //      config.case_sensitive);
       states[i].state = state;
       states[i].start = i * steps;
       states[i].stop = MIN(state->num_lines, (i + 1) * steps);
@@ -1478,6 +1482,8 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
     }
     g_cond_clear(&cond);
     g_mutex_clear(&mutex);
+    for (unsigned int i = 0; i < nt; i++) {
+    }
     for (unsigned int i = 0; i < nt; i++) {
       if (j != states[i].start) {
         memmove(&(state->line_map[j]), &(state->line_map[states[i].start]),

@DaveDavenport
Copy link
Collaborator

Hmm majarno vm is on 10.42-2 .

@DaveDavenport
Copy link
Collaborator

Got PCRE2 10.43 compiled locally and made sure that my rofi use it, but cannot reproduce the crash.

@christian-heusel
Copy link
Author

As I already said, I already didn't find a clear reproducer for the test so far 🤔 It occurs sometimes with regular usage, but not reliably 😢

@DaveDavenport
Copy link
Collaborator

I tried this:

while sleep 0.1;do timeout 0.1 rofi -threads 100000 -show run -filter a; done

for 15 min.

@christian-heusel
Copy link
Author

christian-heusel commented Mar 21, 2024

while sleep 0.1;do timeout 0.1 rofi -threads 100000 -show run -filter a; done

This also does not crash for me, at least not when I tried yesterday and just now ...

The crashes happen quite spaced out during normal usage:

$ coredumpctl list | grep rofi                                                                                                       124 ↵
Wed 2024-03-13 22:14:00 CET 153583 1001 1001 SIGSEGV present  /usr/bin/rofi                            1.1M
Thu 2024-03-14 12:38:05 CET  33324 1001 1001 SIGSEGV present  /usr/bin/rofi                          827.9K
Thu 2024-03-14 14:07:06 CET  50074 1001 1001 SIGSEGV present  /usr/bin/rofi                          829.5K
Thu 2024-03-14 14:11:16 CET  51758 1001 1001 SIGSEGV present  /usr/bin/rofi                          827.2K
Fri 2024-03-15 18:49:34 CET 121147 1001 1001 SIGSEGV present  /usr/bin/rofi                          827.3K
Sat 2024-03-16 15:41:17 CET 118035 1001 1001 SIGSEGV present  /usr/bin/rofi                          826.4K
Sun 2024-03-17 01:58:29 CET  22708 1001 1001 SIGSEGV present  /usr/bin/rofi                          827.9K
Sun 2024-03-17 05:07:57 CET  64476 1001 1001 SIGSEGV present  /usr/bin/rofi                          830.3K
Sun 2024-03-17 14:27:57 CET 163785 1001 1001 SIGSEGV present  /usr/bin/rofi                          828.2K
Sun 2024-03-17 18:46:09 CET 355181 1001 1001 SIGSEGV present  /usr/bin/rofi                          829.8K
Mon 2024-03-18 01:22:16 CET 429097 1001 1001 SIGSEGV present  /usr/bin/rofi                          824.8K
Mon 2024-03-18 01:28:25 CET 430689 1001 1001 SIGSEGV present  /usr/bin/rofi                          827.8K
Mon 2024-03-18 12:11:00 CET  19207 1001 1001 SIGSEGV present  /usr/bin/rofi                          825.6K
Mon 2024-03-18 21:49:39 CET 231508 1001 1001 SIGSEGV present  /usr/bin/rofi                          825.6K
Tue 2024-03-19 13:34:38 CET  44748 1001 1001 SIGSEGV present  /usr/bin/rofi                          828.6K
Tue 2024-03-19 16:26:04 CET 107624 1001 1001 SIGSEGV present  /usr/bin/rofi                          828.3K
Tue 2024-03-19 16:30:00 CET 112073 1001 1001 SIGSEGV present  /usr/bin/rofi                          829.2K
Wed 2024-03-20 15:36:12 CET 549015 1001 1001 SIGSEGV present  /usr/bin/rofi                          814.1K
Thu 2024-03-21 20:43:19 CET 890664 1001 1001 SIGSEGV present  /usr/bin/rofi                          809.4K
Thu 2024-03-21 21:18:20 CET 895395 1001 1001 SIGSEGV present  /usr/bin/rofi                          813.2K

@DaveDavenport
Copy link
Collaborator

ugh, this will make debugging an absolute pain :-P

@dennisschagt
Copy link

For me it seems to reproduce a bit more often.
If I run while sleep 0.1;do timeout 0.1 rofi -threads 100000 -show run -filter a; done, it seems to crash about once every second.

while sleep 0.1;do timeout 0.1 rofi -threads 100000 -show run -filter a; done
timeout: the monitored command dumped core
timeout: the monitored command dumped core
timeout: the monitored command dumped core
...
$ coredumpctl
Thu 2024-03-21 23:07:33 CET   47881 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       696.2K
Thu 2024-03-21 23:07:34 CET   47926 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       696.5K
Thu 2024-03-21 23:07:36 CET   48085 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       694.7K
Thu 2024-03-21 23:07:37 CET   48109 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       695.3K
Thu 2024-03-21 23:07:39 CET   48238 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       696.0K
Thu 2024-03-21 23:07:40 CET   48292 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       694.3K
Thu 2024-03-21 23:07:40 CET   48316 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       695.5K
Thu 2024-03-21 23:07:40 CET   48340 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       695.6K
Thu 2024-03-21 23:07:42 CET   48467 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       697.3K
Thu 2024-03-21 23:07:44 CET   48554 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       696.4K
Thu 2024-03-21 23:07:49 CET   48858 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       696.1K
Thu 2024-03-21 23:07:51 CET   49017 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       695.9K
Thu 2024-03-21 23:07:53 CET   49173 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       695.8K
Thu 2024-03-21 23:07:54 CET   49197 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       697.1K
Thu 2024-03-21 23:07:55 CET   49251 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       695.2K
Thu 2024-03-21 23:07:55 CET   49290 1000 1000 SIGSEGV present  /usr/bin/rofi                                                                       695.2K

I don't have time now, but if it is still useful I can try to debug this myself or run whatever tests you would like during the weekend.

@dennisschagt
Copy link

From what I remember, the crashes started a few days ago.

The last few updates I installed of pcre(2) on Arch Linux:

[2023-02-07T19:56:39+0100] [ALPM] upgraded pcre2 (10.41-1 -> 10.42-2)
[2023-02-07T19:56:47+0100] [ALPM] upgraded lib32-pcre2 (10.41-1 -> 10.42-1)
[2023-08-21T00:00:55+0200] [ALPM] upgraded pcre (8.45-3 -> 8.45-4)
[2024-03-17T16:18:59+0100] [ALPM] upgraded pcre2 (10.42-2 -> 10.43-1)
[2024-03-17T16:19:15+0100] [ALPM] upgraded lib32-pcre2 (10.42-1 -> 10.43-1)

That makes it indeed likely that this is related to version 10.43 of package pcre2.

@christian-heusel
Copy link
Author

That makes it indeed likely that this is related to version 10.43 of package pcre2.

Yeah I have also installed this version of pcre2 on the day the crashes started happening for me (see the coredump log from #1966 (comment)):

[2024-03-13T10:45:15+0100] [ALPM] upgraded pcre2 (10.42-2 -> 10.43-1)

It really bothers me tho that the reproducer from you does not work for me .. Are you getting the same trace as I do? Because it makes me think that we might suffer from different bugs 😆

@DaveDavenport
Copy link
Collaborator

I suspect same bug.. but it might matter what is in the run list :(.

@ravomavain
Copy link

I can still reproduce with the second patch applied over the last commit (6c38a49), with a reproducible input (to avoid comparing different run lists) :

$ while sleep 0.1;do echo -n .;seq 1 1000 | timeout 0.1 ./build/rofi -dmenu -sync -threads 2 -filter 1;done
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................timeout: the monitored command dumped core
...........................................................................................................................................................................................................timeout: the monitored command dumped core
.....................timeout: the monitored command dumped core
.............^C

(if you don't see the rofi window popup, you might need to adjust the timeout)

Here's the coredump timings :

Fri 2024-03-22 00:54:09 CET 201911 1000 1000 SIGSEGV present  /home/romain/src/rofi/build/rofi 701.2K
Fri 2024-03-22 00:54:52 CET 203764 1000 1000 SIGSEGV present  /home/romain/src/rofi/build/rofi 687.9K
Fri 2024-03-22 00:54:57 CET 203971 1000 1000 SIGSEGV present  /home/romain/src/rofi/build/rofi 700.8K
And here's the stack :
(gdb) thread apply all bt

Thread 6 (Thread 0x67ef932006c0 (LWP 203974)):
#0  0x000067ef952190bf in __GI___poll (fds=0x67ef80000b90, nfds=0x2, timeout=0xffffffff) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x000067ef959bb2f6 in g_main_context_poll_unlocked (priority=0x7fffffff, n_fds=0x2, fds=0x67ef80000b90, timeout=<optimized out>, context=0xa82e7e51050) at ../glib/glib/gmain.c:4653
#2  g_main_context_iterate_unlocked.isra.0 (context=0xa82e7e51050, block=block@entry=0x1, dispatch=dispatch@entry=0x1, self=<optimized out>) at ../glib/glib/gmain.c:4344
#3  0x000067ef9595db97 in g_main_loop_run (loop=0xa82e7e51180) at ../glib/glib/gmain.c:4551
#4  0x000067ef9570219c in gdbus_shared_thread_func (user_data=0xa82e7e476c0) at ../glib/gio/gdbusprivate.c:284
#5  0x000067ef9598ea45 in g_thread_proxy (data=0xa82e7de44d0) at ../glib/glib/gthread.c:831
#6  0x000067ef951a955a in start_thread (arg=<optimized out>) at pthread_create.c:447
#7  0x000067ef95226a3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 5 (Thread 0x67ef93c006c0 (LWP 203973)):
#0  0x000067ef952190bf in __GI___poll (fds=0xa82e7e443a0, nfds=0x1, timeout=0xffffffff) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x000067ef959bb2f6 in g_main_context_poll_unlocked (priority=0x7fffffff, n_fds=0x1, fds=0xa82e7e443a0, timeout=<optimized out>, context=0xa82e7e44170) at ../glib/glib/gmain.c:4653
#2  g_main_context_iterate_unlocked.isra.0 (context=context@entry=0xa82e7e44170, block=block@entry=0x1, dispatch=dispatch@entry=0x1, self=<optimized out>) at ../glib/glib/gmain.c:4344
#3  0x000067ef9595b162 in g_main_context_iteration (context=0xa82e7e44170, may_block=may_block@entry=0x1) at ../glib/glib/gmain.c:4414
#4  0x000067ef9595b1b2 in glib_worker_main (data=<optimized out>) at ../glib/glib/gmain.c:6574
#5  0x000067ef9598ea45 in g_thread_proxy (data=0xa82e7e0eb80) at ../glib/glib/gthread.c:831
#6  0x000067ef951a955a in start_thread (arg=<optimized out>) at pthread_create.c:447
#7  0x000067ef95226a3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 4 (Thread 0x67ef946006c0 (LWP 203972)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x000067ef959b6337 in g_cond_wait (cond=0xa82e7e413a8, mutex=0xa82e7e413a0) at ../glib/glib/gthread-posix.c:1552
#2  0x000067ef959281b4 in g_async_queue_pop_intern_unlocked (queue=0xa82e7e413a0, wait=0x1, end_time=0xffffffffffffffff) at ../glib/glib/gasyncqueue.c:425
#3  0x000067ef95990ace in g_thread_pool_spawn_thread (data=<optimized out>) at ../glib/glib/gthreadpool.c:311
#4  0x000067ef9598ea45 in g_thread_proxy (data=0xa82e7de9f70) at ../glib/glib/gthread.c:831
#5  0x000067ef951a955a in start_thread (arg=<optimized out>) at pthread_create.c:447
#6  0x000067ef95226a3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 3 (Thread 0x67ef947ffd00 (LWP 203971)):
#0  futex_wait (private=0x0, expected=0x2, futex_word=0x67ef9511d060 <allocator_lock.lto_priv>) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x67ef9511d060 <allocator_lock.lto_priv>, private=0x0) at lowlevellock.c:49
#2  0x000067ef951ac9b2 in lll_mutex_lock_optimized (mutex=0x67ef9511d060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=mutex@entry=0x67ef9511d060 <allocator_lock.lto_priv>) at pthread_mutex_lock.c:93
#4  0x000067ef9509d1fd in sljit_free_exec (ptr=0x67ef94677010) at src/sljit/allocator_src/sljitExecAllocatorCore.c:254
#5  0x000067ef950cf2c7 in pcre2_jit_compile_8 (code=0xa82e7e56420, options=options@entry=0x1) at src/pcre2_jit_compile.c:14861
#6  0x000067ef95978245 in enable_jit_with_match_options (match_options=0x0, match_info=0xa82e7e730a0) at ../glib/glib/gregex.c:934
#7  g_match_info_next (match_info=match_info@entry=0xa82e7e730a0, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#8  0x000067ef959784a9 in g_regex_match_full (regex=<optimized out>, string=<optimized out>, string_len=string_len@entry=0xffffffffffffffff, start_position=start_position@entry=0x0, match_options=<optimized out>, match_info=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#9  0x000067ef959785af in g_regex_match (regex=<optimized out>, string=<optimized out>, match_options=<optimized out>, match_info=<optimized out>) at ../glib/glib/gregex.c:2204
#10 0x00000a82c9692010 in helper_token_match (tokens=0x7639355f98a0, input=0xa82e7f3c600 "1") at ../source/helper.c:527
#11 0x00000a82c96bda04 in dmenu_token_match (sw=0xa82c96f0300 <dmenu_mode>, tokens=0xa82e7f32080, index=0x0) at ../source/modes/dmenu.c:690
#12 0x00000a82c968f8ca in mode_token_match (mode=0xa82c96f0300 <dmenu_mode>, tokens=0xa82e7f32080, selected_line=0x0) at ../source/mode.c:154
#13 0x00000a82c96894f6 in filter_elements (ts=0x7639355f9990, user_data=0x0) at ../source/view.c:755
#14 0x00000a82c9689490 in rofi_view_call_thread (data=0x7639355f9990, user_data=0x0) at ../source/view.c:744
#15 0x00000a82c968b87b in rofi_view_refilter_real (state=0xa82e7e71c30) at ../source/view.c:1474
#16 0x00000a82c968bfad in rofi_view_refilter (state=0xa82e7e71c30) at ../source/view.c:1579
#17 0x00000a82c968e716 in rofi_view_create (sw=0xa82c96f0300 <dmenu_mode>, input=0xa82e7e71c10 "1", menu_flags=MENU_NORMAL, finalize=0xa82c96bdeb3 <dmenu_finalize>) at ../source/view.c:2531
#18 0x00000a82c96be7a2 in dmenu_mode_dialog () at ../source/modes/dmenu.c:988
#19 0x00000a82c9686159 in startup (data=0x0) at ../source/rofi.c:795
#20 0x000067ef9595cf69 in g_main_dispatch (context=0xa82e7de9290) at ../glib/glib/gmain.c:3476
#21 0x000067ef959bb3a7 in g_main_context_dispatch_unlocked (context=0xa82e7de9290) at ../glib/glib/gmain.c:4284
#22 g_main_context_iterate_unlocked.isra.0 (context=0xa82e7de9290, block=block@entry=0x1, dispatch=dispatch@entry=0x1, self=<optimized out>) at ../glib/glib/gmain.c:4349
#23 0x000067ef9595db97 in g_main_loop_run (loop=0xa82e7de9430) at ../glib/glib/gmain.c:4551
#24 0x00000a82c9687556 in main (argc=0x7, argv=0x7639355f9f88) at ../source/rofi.c:1216

Thread 2 (Thread 0x67ef928006c0 (LWP 203975)):
#0  0x000067ef94ff8e75 in FcSortCompare (aa=0x67ef93df7af0, ab=0x67ef93df7b50) at ../fontconfig/src/fcmatch.c:1112
#1  0x000067ef9515e6ca in msort_with_tmp (p=p@entry=0x67ef927ff770, b=b@entry=0x67ef93df7ad0, n=n@entry=0x21) at qsort.c:239
#2  0x000067ef9515e491 in msort_with_tmp (n=0x21, b=0x67ef93df7ad0, p=0x67ef927ff770) at qsort.c:201
#3  msort_with_tmp (p=p@entry=0x67ef927ff770, b=b@entry=0x67ef93df79d0, n=n@entry=0x41) at qsort.c:210
#4  0x000067ef9515e474 in msort_with_tmp (n=0x41, b=0x67ef93df79d0, p=0x67ef927ff770) at qsort.c:201
#5  msort_with_tmp (p=p@entry=0x67ef927ff770, b=b@entry=0x67ef93df79d0, n=n@entry=0x82) at qsort.c:209
#6  0x000067ef9515e474 in msort_with_tmp (n=0x82, b=0x67ef93df79d0, p=0x67ef927ff770) at qsort.c:201
#7  msort_with_tmp (p=p@entry=0x67ef927ff770, b=b@entry=0x67ef93df79d0, n=n@entry=0x104) at qsort.c:209
#8  0x000067ef9515e491 in msort_with_tmp (n=0x104, b=0x67ef93df79d0, p=0x67ef927ff770) at qsort.c:201
#9  msort_with_tmp (p=p@entry=0x67ef927ff770, b=b@entry=0x67ef93df71b0, n=n@entry=0x208) at qsort.c:210
#10 0x000067ef9515e474 in msort_with_tmp (n=0x208, b=0x67ef93df71b0, p=0x67ef927ff770) at qsort.c:201
#11 msort_with_tmp (p=p@entry=0x67ef927ff770, b=b@entry=0x67ef93df71b0, n=n@entry=0x411) at qsort.c:209
#12 0x000067ef9515e474 in msort_with_tmp (n=0x411, b=0x67ef93df71b0, p=0x67ef927ff770) at qsort.c:201
#13 msort_with_tmp (p=p@entry=0x67ef927ff770, b=b@entry=0x67ef93df71b0, n=n@entry=0x823) at qsort.c:209
#14 0x000067ef9515e474 in msort_with_tmp (n=0x823, b=0x67ef93df71b0, p=0x67ef927ff770) at qsort.c:201
#15 msort_with_tmp (p=p@entry=0x67ef927ff770, b=b@entry=0x67ef93df71b0, n=n@entry=0x1046) at qsort.c:209
#16 0x000067ef9515e8cc in msort_with_tmp (n=0x1046, b=0x67ef93df71b0, p=0x67ef927ff770) at qsort.c:201
#17 __GI___qsort_r (pbase=pbase@entry=0x67ef93df71b0, total_elems=total_elems@entry=0x1046, size=size@entry=0x8, cmp=cmp@entry=0x67ef94ff8e40 <FcSortCompare>, arg=arg@entry=0x0) at qsort.c:393
#18 0x000067ef9515ec5c in __GI_qsort (b=b@entry=0x67ef93df71b0, n=n@entry=0x1046, s=s@entry=0x8, cmp=cmp@entry=0x67ef94ff8e40 <FcSortCompare>) at qsort.c:405
#19 0x000067ef9500111e in IA__FcFontSetSort (config=<optimized out>, sets=sets@entry=0xa82e7f4cdc0, nsets=nsets@entry=0x1, p=<optimized out>, trim=trim@entry=0x1, csp=csp@entry=0x0, result=0x67ef927ffd14) at ../fontconfig/src/fcmatch.c:1348
#20 0x000067ef94b42d2a in sort_in_thread (task_data=0xa82e7f4cdb0) at ../pango/pango/pangofc-fontmap.c:923
#21 fc_thread_func (data=0xa82e7e97260) at ../pango/pango/pangofc-fontmap.c:972
#22 0x000067ef9598ea45 in g_thread_proxy (data=0xa82e7e970c0) at ../glib/glib/gthread.c:831
#23 0x000067ef951a955a in start_thread (arg=<optimized out>) at pthread_create.c:447
#24 0x000067ef95226a3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 1 (Thread 0x67ef90e006c0 (LWP 203976)):
#0  sljit_remove_free_block (free_block=0x67ef94686ff0) at src/sljit/allocator_src/sljitExecAllocatorCore.c:137
#1  sljit_free_exec (ptr=0x67ef94686fc0) at src/sljit/allocator_src/sljitExecAllocatorCore.c:281
#2  0x000067ef950cf2c7 in pcre2_jit_compile_8 (code=0x67ef74000d40, options=options@entry=0x1) at src/pcre2_jit_compile.c:14861
#3  0x000067ef95978245 in enable_jit_with_match_options (match_options=0x0, match_info=0x67ef74000e30) at ../glib/glib/gregex.c:934
#4  g_match_info_next (match_info=match_info@entry=0x67ef74000e30, error=error@entry=0x0) at ../glib/glib/gregex.c:1117
#5  0x000067ef959784a9 in g_regex_match_full (regex=<optimized out>, string=<optimized out>, string_len=string_len@entry=0xffffffffffffffff, start_position=start_position@entry=0x0, match_options=<optimized out>, match_info=0x0, error=0x0) at ../glib/glib/gregex.c:2295
#6  0x000067ef959785af in g_regex_match (regex=<optimized out>, string=<optimized out>, match_options=<optimized out>, match_info=<optimized out>) at ../glib/glib/gregex.c:2204
#7  0x00000a82c9692010 in helper_token_match (tokens=0x67ef90dffc10, input=0xa82e7f39e20 "502") at ../source/helper.c:527
#8  0x00000a82c96bda04 in dmenu_token_match (sw=0xa82c96f0300 <dmenu_mode>, tokens=0xa82e7f3c5c0, index=0x1f5) at ../source/modes/dmenu.c:690
#9  0x00000a82c968f8ca in mode_token_match (mode=0xa82c96f0300 <dmenu_mode>, tokens=0xa82e7f3c5c0, selected_line=0x1f5) at ../source/mode.c:154
#10 0x00000a82c96894f6 in filter_elements (ts=0x7639355f99e8, user_data=0x0) at ../source/view.c:755
#11 0x00000a82c9689490 in rofi_view_call_thread (data=0x7639355f99e8, user_data=0x0) at ../source/view.c:744
#12 0x000067ef95991523 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/glib/gthreadpool.c:350
#13 0x000067ef9598ea45 in g_thread_proxy (data=0x67ef8c000b90) at ../glib/glib/gthread.c:831
#14 0x000067ef951a955a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x000067ef95226a3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

@dennisschagt
Copy link

I just ran git bisect on pcre2.
It looks like the first commit on which I can reproduce the crashes is PCRE2Project/pcre2@d84f255
I did not yet look into the actual changes but, from the title, it does look related to our backtraces.

Are you getting the same trace as I do? Because it makes me think that we might suffer from different bugs

Yes, from a quick check it looks exactly the same as your backtrace (same function names, same number of frames between clone3 and sljit_remove_free_block)

@dennisschagt
Copy link

Got PCRE2 10.43 compiled locally and made sure that my rofi use it, but cannot reproduce the crash.

Just a quick check.
It looks like the Arch Linux package is build after configuring --enable-jit.
https://gitlab.archlinux.org/archlinux/packaging/packages/pcre2/-/blob/d14662749c271e381b47fdceb1765e2fbd8a1ac9/PKGBUILD#L37

Did you also apply that configuration?

@DaveDavenport
Copy link
Collaborator

Yes, I copied the arch package build flags.

@DaveDavenport
Copy link
Collaborator

I just ran git bisect on pcre2. It looks like the first commit on which I can reproduce the crashes is PCRE2Project/pcre2@d84f255 I did not yet look into the actual changes but, from the title, it does look related to our backtraces.

Are you getting the same trace as I do? Because it makes me think that we might suffer from different bugs

Yes, from a quick check it looks exactly the same as your backtrace (same function names, same number of frames between clone3 and sljit_remove_free_block)

Thanks. When I have some time I'll look more into this.

@DaveDavenport
Copy link
Collaborator

kay on debian and compiled pcre2 I can reproduce it.. progress

@DaveDavenport
Copy link
Collaborator

#0  sljit_remove_free_block (free_block=0x7fe109bffff0) at src/sljit/allocator_src/sljitExecAllocatorCore.c:140
140	    free_block->next->prev = free_block->prev;
[Current thread is 1 (Thread 0x7fe1037fe6c0 (LWP 151385))]
(gdb) print free_block
$1 = (struct free_block *) 0x7fe109bffff0
(gdb) print free_block->next
$2 = (struct free_block *) 0x10102464c457f
(gdb) print free_block->next->prev
Cannot access memory at address 0x10102464c4597

so prev pointer is invalid.. memory corruption?

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Mar 22, 2024

not sure is relevant. PCRE2Project/pcre2#318
rofi does reuse GRegex over threads.. above patch creates a unique in the thread itself, but no fix.
Where it crashes is guarded by locks.

@lbonn
Copy link
Collaborator

lbonn commented Mar 23, 2024

On the other hand glib explicitly presents GRegex as thread-safe https://docs.gtk.org/glib/struct.Regex.html. Something is funny here...

pcre2 multi-threading doc is here https://www.pcre.org/current/doc/html/pcre2api.html#SEC17. Looking at the glib code may bring some insight...

@lbonn
Copy link
Collaborator

lbonn commented Mar 24, 2024

Glib and rofi seemed fine from a cursory look.

I just ran git bisect on pcre2. It looks like the first commit on which I can reproduce the crashes is PCRE2Project/pcre2@d84f255 I did not yet look into the actual changes but, from the title, it does look related to our backtraces.

@dennisschagt Thanks for bisecting this by the way! From this set of changes, I think this is the most suspicious part:

diff --git a/src/sljit/sljitExecAllocator.c b/src/sljit/allocator_src/sljitExecAllocatorCore.c
similarity index 64%
rename from src/sljit/sljitExecAllocator.c
rename to src/sljit/allocator_src/sljitExecAllocatorCore.c
index 92d940d..6cd3911 100644
--- a/src/sljit/sljitExecAllocator.c
+++ b/src/sljit/allocator_src/sljitExecAllocatorCore.c
@@ -332,9 +237,12 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
                header->size = chunk_size;
                next_header = AS_BLOCK_HEADER(header, chunk_size);
        }
+       SLJIT_ALLOCATOR_UNLOCK();
        next_header->size = 1;
        next_header->prev_size = chunk_size;
-       SLJIT_ALLOCATOR_UNLOCK();
+#ifdef SLJIT_HAS_EXECUTABLE_OFFSET
+       next_header->executable_offset = executable_offset;
+#endif /* SLJIT_HAS_EXECUTABLE_OFFSET */
        return MEM_START(header);
 }

Some prev_size fields are read in sljit_free_exec, so it's likely it's not thread-safe.

If someone can test if moving back SLIT_ALLOCATOR_UNLOCK after next_header->prev_size = chunk_size; fixes the issue, that would be great. Otherwise, I'll see if I have time in the next few days.

@DaveDavenport
Copy link
Collaborator

Looks like it fixes it for me (tm).

@crumblingstatue
Copy link

For what it's worth, valgrind reports tons of errors every time when using rofi, so reproducibility is not an issue for me as long as I'm running rofi using valgrind. Unless they are false positives, they should probably be fixed.

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Mar 29, 2024

For me most of the valgrind errors are in the font library pango uses and other dependencies. A lot of these can be hidden by using the suppression files shipped for these libraries.

I think this one is kinda confirmed to be a bug in pcre lib

@DaveDavenport
Copy link
Collaborator

Closing as it seems to be fixed upstream in PCRE. Regrettable we need to wait for this to trickle down into distributions.

Workaround is probably running with -threads 1

@christian-heusel
Copy link
Author

@lbonn was already kind enough to submit a backport MR to Arch Linux: https://gitlab.archlinux.org/archlinux/packaging/packages/pcre2/-/merge_requests/4

@lbonn
Copy link
Collaborator

lbonn commented Apr 4, 2024

:)

Otherwise, it should mainly affect Debian experimental and Fedora 41. On NixOs unstable, the JIT is accidentally disabled NixOS/nixpkgs#300056

Copy link

github-actions bot commented May 6, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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

No branches or pull requests

6 participants