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

Waybar 0.10.3, libcava 0.10.1, segfaults with cava module enabled in bar configuration #3276

Closed
OriginCode opened this issue May 16, 2024 · 18 comments
Labels
bug Something isn't working cava custom inhibitor

Comments

@OriginCode
Copy link

OriginCode commented May 16, 2024

Tested with --buildtype=debug.

waybar -l trace:

[2024-05-16 02:15:30.380] [debug] Try expanding: $XDG_CONFIG_HOME/waybar/config
[2024-05-16 02:15:30.380] [debug] Try expanding: $XDG_CONFIG_HOME/waybar/config.jsonc
[2024-05-16 02:15:30.380] [debug] Try expanding: $HOME/.config/waybar/config
[2024-05-16 02:15:30.380] [debug] Try expanding: $HOME/.config/waybar/config.jsonc
[2024-05-16 02:15:30.380] [debug] Found config file: $HOME/.config/waybar/config.jsonc
[2024-05-16 02:15:30.380] [info] Using configuration file /home/origincode/.config/waybar/config.jsonc
[2024-05-16 02:15:30.385] [info] Discovered appearance 'dark'
[2024-05-16 02:15:30.385] [debug] Try expanding: $XDG_CONFIG_HOME/waybar/style-dark.css
[2024-05-16 02:15:30.385] [debug] Try expanding: $XDG_CONFIG_HOME/waybar/style.css
[2024-05-16 02:15:30.385] [debug] Try expanding: $HOME/.config/waybar/style-dark.css
[2024-05-16 02:15:30.385] [debug] Try expanding: $HOME/.config/waybar/style.css
[2024-05-16 02:15:30.385] [debug] Found config file: $HOME/.config/waybar/style.css
[2024-05-16 02:15:30.385] [info] Using CSS file /home/origincode/.config/waybar/style.css
[2024-05-16 02:15:30.393] [debug] Output detection done: DP-1 (GSM LG ULTRAGEAR 0x0001D493)
[2024-05-16 02:15:30.395] [warning] Mapping is not an object
fish: Job 1, './build/waybar -l trace' terminated by signal SIGSEGV (Address boundary error)

gdb waybar:

(gdb) bt
#0  __GI_strlen () at ../sysdeps/x86_64/multiarch/strlen-sse2.S:142
#1  0x0000555555593d2f in std::char_traits<char>::length (__s=0x0) at /usr/include/c++/13.2.0/bits/char_traits.h:409
#2  0x00005555557f0e34 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::replace (this=0x7fffffffb4f0, __pos=0, __n1=16, __s=0x0)
    at /usr/include/c++/13.2.0/bits/basic_string.h:2221
#3  0x00005555557ee2f5 in waybar::modules::Cava::Cava (this=0x555555cc3570, id="", config=...) at ../src/modules/cava.cpp:15
#4  0x0000555555591fde in waybar::Factory::makeModule (this=0x7fffffffc8c0, name="cava", pos="modules-left") at ../src/factory.cpp:311
#5  0x0000555555618ade in waybar::Bar::getModules (this=0x555555addda0, factory=..., pos="modules-left", group=0x0) at ../src/bar.cpp:495
#6  0x00005555556190e0 in waybar::Bar::setupWidgets (this=0x555555addda0) at ../src/bar.cpp:543
#7  0x00005555556167b2 in waybar::Bar::Bar (this=0x555555addda0, w_output=0x555555bca1c0, w_config=...) at ../src/bar.cpp:279
#8  0x0000555555631a74 in std::make_unique<waybar::Bar, waybar::waybar_output*, Json::Value const&> () at /usr/include/c++/13.2.0/bits/unique_ptr.h:1070
#9  0x000055555562523a in waybar::Client::handleOutputDone (data=0x555555bca1c0) at ../src/client.cpp:83
#10 0x00007ffff65a6052 in ffi_call_unix64 () at ../src/x86/unix64.S:104
#11 0x00007ffff65a4917 in ffi_call_int (cif=cif@entry=0x7fffffffcf70, fn=fn@entry=0x5555556250ee <waybar::Client::handleOutputDone(void*, zxdg_output_v1*)>, rvalue=<optimized out>,
    rvalue@entry=0x0, avalue=<optimized out>, closure=closure@entry=0x0) at ../src/x86/ffi64.c:673
#12 0x00007ffff65a504d in ffi_call
    (cif=cif@entry=0x7fffffffcf70, fn=0x5555556250ee <waybar::Client::handleOutputDone(void*, zxdg_output_v1*)>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0x7fffffffd040)
    at ../src/x86/ffi64.c:710
#13 0x00007ffff7f7b6e1 in wl_closure_invoke (closure=closure@entry=0x555555b22f00, flags=flags@entry=1, target=<optimized out>,
    target@entry=0x555555adcfe0, opcode=opcode@entry=2, data=<optimized out>) at ../src/connection.c:1025
#14 0x00007ffff7f77be8 in dispatch_event (display=display@entry=0x5555559af380, queue=0x5555559af470) at ../src/wayland-client.c:1631
#15 0x00007ffff7f79534 in dispatch_queue (queue=0x5555559af470, display=0x5555559af380) at ../src/wayland-client.c:1777
#16 wl_display_dispatch_queue_pending (display=0x5555559af380, queue=0x5555559af470) at ../src/wayland-client.c:2019
#17 0x00007ffff7f7958c in wl_display_dispatch_pending (display=<optimized out>) at ../src/wayland-client.c:2082
#18 0x00007ffff76da044 in _gdk_wayland_display_queue_events (display=<optimized out>) at ../gdk/wayland/gdkeventsource.c:201
#19 0x00007ffff76a83f9 in gdk_display_get_event (display=0x5555559d3480 [GdkWaylandDisplay]) at ../gdk/gdkdisplay.c:442
#20 0x00007ffff76e2a12 in gdk_event_source_dispatch (base=<optimized out>, callback=<optimized out>, data=<optimized out>) at ../gdk/wayland/gdkeventsource.c:120
#21 0x00007ffff6a95498 in g_main_dispatch (context=context@entry=0x5555559dbe60) at ../glib/gmain.c:3344
#22 0x00007ffff6a985a7 in g_main_context_dispatch_unlocked (context=0x5555559dbe60) at ../glib/gmain.c:4152
#23 g_main_context_iterate_unlocked (context=context@entry=0x5555559dbe60, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4217
#24 0x00007ffff6a98bac in g_main_context_iteration (context=context@entry=0x5555559dbe60, may_block=may_block@entry=1) at ../glib/gmain.c:4282
#25 0x00007ffff6cfb42d in g_application_run (application=0x5555559a4fe0 [gtkmm__GtkApplication], argc=<optimized out>, argv=<optimized out>) at ../gio/gapplication.c:2712
#26 0x00005555556275de in waybar::Client::main (this=0x55555591d780, argc=1, argv=0x7fffffffde48) at ../src/client.cpp:287
#27 0x0000555555611ef0 in main (argc=1, argv=0x7fffffffde48) at ../src/main.cpp:106

Seems to be related to config file loading?

@github-actions github-actions bot added bug Something isn't working cava custom inhibitor labels May 16, 2024
@OriginCode
Copy link
Author

OriginCode commented May 16, 2024

Yeah it seems to be something wrong when $XDG_CONFIG_HOME is empty.

According to https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html , the value should default to $HOME/.config if not set.

@LukashonakV
Copy link
Contributor

Yeah, need to add validation for $XDG_CONFIG_HOME.

@LukashonakV
Copy link
Contributor

Hi @OriginCode , fix is merged. Please try again with the master branch

@OriginCode
Copy link
Author

OriginCode commented May 18, 2024

Hi @OriginCode , fix is merged. Please try again with the master branch

Yeah it doesn't segfault now as it just cannot find the file lol.

You might want to consider implement the spec to check $HOME/.config as a fallback. There are distros that do not manually set $XDG_CONFIG_HOME.

@LukashonakV
Copy link
Contributor

Checking your point...

@LukashonakV
Copy link
Contributor

Hi @OriginCode , thank you for your feedback. Related merge request is created to the original cava upstream. See karlstav/cava#565. Once it's done I'll do sync with libcava and bump libcava version.

@LukashonakV
Copy link
Contributor

Hi @OriginCode , please check with the new commits. Now it should be fine. If it's so, please close the issue

@OriginCode
Copy link
Author

@LukashonakV It still doesn't recognize $XDG_CONFIG_HOME when the variable is empty :(
Also there seems to be some weird issue in the log (see the path in the error message, it's not the same as in my config):
圖片

@LukashonakV
Copy link
Contributor

LukashonakV commented May 27, 2024

Hi @OriginCode, can you explain what you're expecting from cava when the environment variable is not defined in the system ?
Thank you for response, I reproduced the issue with the garbage in the final config path. Need to check what's wrong with it.

@OriginCode
Copy link
Author

@LukashonakV It should look for $HOME/.config as fallback to $XDG_HOME_CONFIG.

@LukashonakV LukashonakV mentioned this issue Sep 27, 2024
@LukashonakV
Copy link
Contributor

Hi @OriginCode , I fixed the issue when libcava expands user variables and constructs file path for opening. Please update waybar or libcava-0.10.3 and let me know about results. Thanks

@OriginCode
Copy link
Author

Hi @OriginCode , I fixed the issue when libcava expands user variables and constructs file path for opening. Please update waybar or libcava-0.10.3 and let me know about results. Thanks

I still get [error] Error loading config. Unable to open file '${XDG_CONFIG_HOME}/cava/cava.conf', exiting... with master branch waybar and libcava 0.10.3.

@LukashonakV
Copy link
Contributor

@OriginCode you should use $XDG_CONFIG_HOME. NOT ${XDG_CONFIG_HOME}

@OriginCode
Copy link
Author

OriginCode commented Sep 29, 2024

@OriginCode you should use $XDG_CONFIG_HOME. NOT ${XDG_CONFIG_HOME}

Both don't work on my end. :(
[error] Error loading config. Unable to open file '$XDG_CONFIG_HOME/cava/cava.conf', exiting...

@LukashonakV
Copy link
Contributor

LukashonakV commented Sep 29, 2024

This error means you have not configured xdg variable .
env | grep -i xdg

@OriginCode
Copy link
Author

This error means you have not configured xdg variable . env | grep -i xdg

As I mentioned before, according to https://specifications.freedesktop.org/basedir-spec/latest/index.html#variables when the variable is not set, it should look up $HOME/.config as a fallback :)

@LukashonakV
Copy link
Contributor

LukashonakV commented Sep 29, 2024

This error means you have not configured xdg variable . env | grep -i xdg

As I mentioned before, according to https://specifications.freedesktop.org/basedir-spec/latest/index.html#variables when the variable is not set, it should look up $HOME/.config as a fallback :)

Actually, I'm still thinking of fallbacks... the reason, to me it seems obvious it's the user responsibility to provide correct content into the API. When the fallback happened, it was not clear which config now is used

So, for now, fallback mechanic is not considered. And the new libcava version just fixed memory leaking

@OriginCode
Copy link
Author

OriginCode commented Sep 29, 2024

This error means you have not configured xdg variable . env | grep -i xdg

As I mentioned before, according to https://specifications.freedesktop.org/basedir-spec/latest/index.html#variables when the variable is not set, it should look up $HOME/.config as a fallback :)

Actually, I'm still thinking of fallbacks... the reason, to me it seems obvious it's the user responsibility to provide correct content into the API. When the fallback happened, it was not clear which config now is used

So, for now, fallback mechanic is not considered.

No pressure, at least $HOME works fine for now. I know it's weird to implement fallback for some environment variables. Just saying that XDG spec is followed and used widely by Linux distributions, it may be weird to users using the variable in the way the spec describes. Thank you for fixing the segfault ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cava custom inhibitor
Projects
None yet
Development

No branches or pull requests

2 participants