Skip to content

Commit 0e03c7a

Browse files
committed
fix a segfault on signals received after main returns
The waybar process does not exit instantaneously. Signals may be recevied after main has started freeing resources. When a worker thread is in `fgets` this time window can last forever. An easy way to duplicate the crash is pressing ^C twice with a Hyprland module. Thread 1 "waybar" received signal SIGSEGV, Segmentation fault. spdlog::sinks::sink::should_log (this=0x5f620b542ca5, msg_level=spdlog::level::info) at /usr/src/debug/spdlog/spdlog-1.14.1/include/spdlog/sinks/sink-inl.h:13 13 return msg_level >= level_.load(std::memory_order_relaxed); (gdb) p $_siginfo._sifields._sigfault.si_addr $1 = (void *) 0x5f620b542cad
1 parent 280f11e commit 0e03c7a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ int main(int argc, char* argv[]) {
107107
ret = client->main(argc, argv);
108108
} while (reload);
109109

110+
std::signal(SIGUSR1, SIG_IGN);
111+
std::signal(SIGUSR2, SIG_IGN);
112+
std::signal(SIGINT, SIG_IGN);
113+
110114
delete client;
111115
return ret;
112116
} catch (const std::exception& e) {

0 commit comments

Comments
 (0)