Skip to content

Fix Hyprland IPC thread sanitizer warning, other IPC & general fixes#4359

Merged
Alexays merged 5 commits into
Alexays:masterfrom
zjeffer:fix/zjeffer/thread-sanitizer-warning
Oct 5, 2025
Merged

Fix Hyprland IPC thread sanitizer warning, other IPC & general fixes#4359
Alexays merged 5 commits into
Alexays:masterfrom
zjeffer:fix/zjeffer/thread-sanitizer-warning

Conversation

@zjeffer

@zjeffer zjeffer commented Aug 10, 2025

Copy link
Copy Markdown
Contributor
  • Fixes hyprland/windowcount creating a separate IPC instance, instead of accessing the singleton.
  • Add a tsan.supp file that can be used to suppress tsan issues when debugging with thread sanitizer enabled. GDK/GLib has tons of issues with data races, which aren't relevant when fixing bugs with Waybar itself.
  • Also add an asan.supp file for address sanitizer
  • Fix false positive warning getting thrown when swap-icon-label is not set in the config.
==================
WARNING: ThreadSanitizer: data race (pid=1189116)
  Write of size 1 at 0x55e211e06968 by main thread:
    #0 waybar::modules::hyprland::Workspaces::Workspaces(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, waybar::Bar const&, Json::Value const&) ../src/modules/hyprland/workspaces.cpp:21 (waybar+0x2598bc) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #1 waybar::Factory::makeModule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const ../src/factory.cpp:211 (waybar+0x3ae07) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #2 waybar::Bar::getModules(waybar::Factory const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, waybar::Group*) ../src/bar.cpp:503 (waybar+0x103a19) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #3 waybar::Bar::setupWidgets() ../src/bar.cpp:560 (waybar+0x104275) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #4 waybar::Bar::Bar(waybar::waybar_output*, Json::Value const&) ../src/bar.cpp:280 (waybar+0x101358) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #5 std::__detail::_MakeUniq<waybar::Bar>::__single_object std::make_unique<waybar::Bar, waybar::waybar_output*, Json::Value const&>(waybar::waybar_output*&&, Json::Value const&) <null> (waybar+0x126e97) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #6 waybar::Client::handleOutputDone(void*, zxdg_output_v1*) ../src/client.cpp:84 (waybar+0x116421) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #7 <null> <null> (libffi.so.8+0x7ac5) (BuildId: 02fec367864097384b082accc299b6e74c83454b)
    #8 main ../src/main.cpp:107 (waybar+0xfb9c2) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)

  Previous read of size 1 at 0x55e211e06968 by thread T7:
    #0 waybar::modules::hyprland::IPC::socketListener() ../src/modules/hyprland/backend.cpp:81 (waybar+0x241b26) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #1 operator() ../src/modules/hyprland/backend.cpp:48 (waybar+0x24175f) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #2 __invoke_impl<void, waybar::modules::hyprland::IPC::IPC()::<lambda()> > /usr/include/c++/15.1.1/bits/invoke.h:63 (waybar+0x24321d) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #3 __invoke<waybar::modules::hyprland::IPC::IPC()::<lambda()> > /usr/include/c++/15.1.1/bits/invoke.h:98 (waybar+0x243198) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #4 _M_invoke<0> /usr/include/c++/15.1.1/bits/std_thread.h:303 (waybar+0x24310e) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #5 operator() /usr/include/c++/15.1.1/bits/std_thread.h:310 (waybar+0x2430b8) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #6 _M_run /usr/include/c++/15.1.1/bits/std_thread.h:255 (waybar+0x243072) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #7 execute_native_thread_routine /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104 (libstdc++.so.6+0xe55a3) (BuildId: b7f565a7c08824e8865f66d42992e5dc01059f01)

  Location is global 'waybar::modules::hyprland::modulesReady' of size 1 at 0x55e211e06968 (waybar+0x53f968)

  Thread T7 (tid=1189208, running) created by main thread at:
    #0 pthread_create /usr/src/debug/gcc/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:1041 (libtsan.so.2+0x5fb47) (BuildId: c904c43459cc4e1fee6965f1448d8b3c05385b21)
    #1 __gthread_create(unsigned long*, void* (*)(void*), void*) /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:709 (libstdc++.so.6+0xe56a1) (BuildId: b7f565a7c08824e8865f66d42992e5dc01059f01)
    #2 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:172 (libstdc++.so.6+0xe56a1)
    #3 waybar::modules::hyprland::IPC::IPC() ../src/modules/hyprland/backend.cpp:48 (waybar+0x241822) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #4 waybar::modules::hyprland::IPC::inst() ../src/modules/hyprland/backend.cpp:68 (waybar+0x241a48) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #5 waybar::modules::hyprland::Workspaces::Workspaces(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, waybar::Bar const&, Json::Value const&) ../src/modules/hyprland/workspaces.cpp:20 (waybar+0x259887) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #6 waybar::Factory::makeModule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const ../src/factory.cpp:211 (waybar+0x3ae07) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #7 waybar::Bar::getModules(waybar::Factory const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, waybar::Group*) ../src/bar.cpp:503 (waybar+0x103a19) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #8 waybar::Bar::setupWidgets() ../src/bar.cpp:560 (waybar+0x104275) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #9 waybar::Bar::Bar(waybar::waybar_output*, Json::Value const&) ../src/bar.cpp:280 (waybar+0x101358) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #10 std::__detail::_MakeUniq<waybar::Bar>::__single_object std::make_unique<waybar::Bar, waybar::waybar_output*, Json::Value const&>(waybar::waybar_output*&&, Json::Value const&) <null> (waybar+0x126e97) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #11 waybar::Client::handleOutputDone(void*, zxdg_output_v1*) ../src/client.cpp:84 (waybar+0x116421) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)
    #12 <null> <null> (libffi.so.8+0x7ac5) (BuildId: 02fec367864097384b082accc299b6e74c83454b)
    #13 main ../src/main.cpp:107 (waybar+0xfb9c2) (BuildId: d5dde6d1937144c65f22efb47a25f4b5d959ba57)

SUMMARY: ThreadSanitizer: data race ../src/modules/hyprland/workspaces.cpp:21 in waybar::modules::hyprland::Workspaces::Workspaces(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, waybar::Bar const&, Json::Value const&)
==================

Potential fix for #3975 This won't fix #3975 (#4408 will), but should be merged regardless.

@zjeffer zjeffer force-pushed the fix/zjeffer/thread-sanitizer-warning branch 7 times, most recently from 1eb26ba to c14b7a9 Compare August 11, 2025 18:09
@zjeffer zjeffer changed the title Fix thread sanitizer warning in Hyprland IPC Fix Hyprland IPC thread sanitizer warning, other IPC & general fixes Aug 11, 2025
@zjeffer zjeffer force-pushed the fix/zjeffer/thread-sanitizer-warning branch from c14b7a9 to 079c700 Compare August 12, 2025 17:41
@zjeffer zjeffer force-pushed the fix/zjeffer/thread-sanitizer-warning branch from 1f43a27 to 3c3164e Compare August 19, 2025 21:56
@Alexays Alexays merged commit 0c41cf4 into Alexays:master Oct 5, 2025
7 of 9 checks passed
@khaneliman khaneliman deleted the fix/zjeffer/thread-sanitizer-warning branch October 7, 2025 13:12
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.

waybar stops talking to hyprland ipc after a display is plugged in/out

2 participants