Skip to content

Commit

Permalink
fix a segfault on signals received after main returns
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cfillion committed Oct 16, 2024
1 parent 280f11e commit 0e03c7a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ int main(int argc, char* argv[]) {
ret = client->main(argc, argv);
} while (reload);

std::signal(SIGUSR1, SIG_IGN);
std::signal(SIGUSR2, SIG_IGN);
std::signal(SIGINT, SIG_IGN);

delete client;
return ret;
} catch (const std::exception& e) {
Expand Down

0 comments on commit 0e03c7a

Please sign in to comment.