From f16a6c7dcf789b8ea7a21a63247d107c78a32131 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:51:07 +0000 Subject: [PATCH 1/6] Initial plan From c34b1b6a19161b23142d5fb3c3ac365581023141 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:53:47 +0000 Subject: [PATCH 2/6] Fix unhandled JSON exception in signal handlers Cache signal value during module construction to avoid accessing JSON config in signal handler context. This prevents crashes when signal field is missing or not an integer type. - Custom module: Cache signal_ value in constructor - Image module: Cache signal_ value in constructor - Both modules: Use cached value in refresh() method Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com> --- include/modules/custom.hpp | 1 + include/modules/image.hpp | 1 + src/modules/custom.cpp | 5 +++-- src/modules/image.cpp | 6 ++++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/modules/custom.hpp b/include/modules/custom.hpp index 6c17c6e4..a00faaa5 100644 --- a/include/modules/custom.hpp +++ b/include/modules/custom.hpp @@ -42,6 +42,7 @@ class Custom : public ALabel { int pid_; util::command::res output_; util::JsonParser parser_; + int signal_; // Cached signal value to avoid JSON access in signal handler util::SleeperThread thread_; }; diff --git a/include/modules/image.hpp b/include/modules/image.hpp index 510dad94..e31de0fc 100644 --- a/include/modules/image.hpp +++ b/include/modules/image.hpp @@ -33,6 +33,7 @@ class Image : public AModule { int size_; std::chrono::milliseconds interval_; util::command::res output_; + int signal_; // Cached signal value to avoid JSON access in signal handler util::SleeperThread thread_; }; diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index d75633e9..a3ea7b27 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -13,7 +13,8 @@ waybar::modules::Custom::Custom(const std::string& name, const std::string& id, tooltip_format_enabled_{config_["tooltip-format"].isString()}, percentage_(0), fp_(nullptr), - pid_(-1) { + pid_(-1), + signal_(config_["signal"].isInt() ? config_["signal"].asInt() : -1) { if (config.isNull()) { spdlog::warn("There is no configuration for 'custom/{}', element will be hidden", name); } @@ -136,7 +137,7 @@ void waybar::modules::Custom::waitingWorker() { } void waybar::modules::Custom::refresh(int sig) { - if (sig == SIGRTMIN + config_["signal"].asInt()) { + if (signal_ != -1 && sig == SIGRTMIN + signal_) { thread_.wake_up(); } } diff --git a/src/modules/image.cpp b/src/modules/image.cpp index 173aabd3..4e830608 100644 --- a/src/modules/image.cpp +++ b/src/modules/image.cpp @@ -1,7 +1,9 @@ #include "modules/image.hpp" waybar::modules::Image::Image(const std::string& id, const Json::Value& config) - : AModule(config, "image", id), box_(Gtk::ORIENTATION_HORIZONTAL, 0) { + : AModule(config, "image", id), + box_(Gtk::ORIENTATION_HORIZONTAL, 0), + signal_(config_["signal"].isInt() ? config_["signal"].asInt() : -1) { box_.pack_start(image_); box_.set_name("image"); if (!id.empty()) { @@ -41,7 +43,7 @@ void waybar::modules::Image::delayWorker() { } void waybar::modules::Image::refresh(int sig) { - if (sig == SIGRTMIN + config_["signal"].asInt()) { + if (signal_ != -1 && sig == SIGRTMIN + signal_) { thread_.wake_up(); } } From 4cadae83b3d210fc3894d097ab097eb275260d9c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:54:14 +0000 Subject: [PATCH 3/6] Improve comments for cached signal values Clarify that -1 indicates signal-based refresh is disabled Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com> --- include/modules/custom.hpp | 2 +- include/modules/image.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/modules/custom.hpp b/include/modules/custom.hpp index a00faaa5..40406e96 100644 --- a/include/modules/custom.hpp +++ b/include/modules/custom.hpp @@ -42,7 +42,7 @@ class Custom : public ALabel { int pid_; util::command::res output_; util::JsonParser parser_; - int signal_; // Cached signal value to avoid JSON access in signal handler + int signal_; // Cached signal value (-1 = disabled) to avoid JSON access in signal handler util::SleeperThread thread_; }; diff --git a/include/modules/image.hpp b/include/modules/image.hpp index e31de0fc..40be856a 100644 --- a/include/modules/image.hpp +++ b/include/modules/image.hpp @@ -33,7 +33,7 @@ class Image : public AModule { int size_; std::chrono::milliseconds interval_; util::command::res output_; - int signal_; // Cached signal value to avoid JSON access in signal handler + int signal_; // Cached signal value (-1 = disabled) to avoid JSON access in signal handler util::SleeperThread thread_; }; From 19ede92d7f88e8e7ab5333094d13d4a3c0819f6d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:54:36 +0000 Subject: [PATCH 4/6] Complete fix for unhandled exception in signal handler Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com> --- _codeql_detected_source_root | 1 + 1 file changed, 1 insertion(+) create mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 00000000..945c9b46 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file From 74fb2f252fb484887726cfa64bbaa8fb0b19f620 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:54:48 +0000 Subject: [PATCH 5/6] Remove CodeQL artifact from repository Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com> --- .gitignore | 1 + _codeql_detected_source_root | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 120000 _codeql_detected_source_root diff --git a/.gitignore b/.gitignore index 8bf6481d..f42bf85e 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ result result-* .ccls-cache +_codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root deleted file mode 120000 index 945c9b46..00000000 --- a/_codeql_detected_source_root +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file From 0a8b7b096a3e4295ad729659c229fba2d1930828 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:57:08 +0000 Subject: [PATCH 6/6] Simplify fix: only add isInt() check in refresh methods Changed approach per maintainer feedback - instead of caching signal values, just add isInt() check before accessing config_["signal"].asInt() in refresh() methods. This is simpler and more minimal. Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com> --- include/modules/custom.hpp | 1 - include/modules/image.hpp | 1 - src/modules/custom.cpp | 5 ++--- src/modules/image.cpp | 6 ++---- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/modules/custom.hpp b/include/modules/custom.hpp index 40406e96..6c17c6e4 100644 --- a/include/modules/custom.hpp +++ b/include/modules/custom.hpp @@ -42,7 +42,6 @@ class Custom : public ALabel { int pid_; util::command::res output_; util::JsonParser parser_; - int signal_; // Cached signal value (-1 = disabled) to avoid JSON access in signal handler util::SleeperThread thread_; }; diff --git a/include/modules/image.hpp b/include/modules/image.hpp index 40be856a..510dad94 100644 --- a/include/modules/image.hpp +++ b/include/modules/image.hpp @@ -33,7 +33,6 @@ class Image : public AModule { int size_; std::chrono::milliseconds interval_; util::command::res output_; - int signal_; // Cached signal value (-1 = disabled) to avoid JSON access in signal handler util::SleeperThread thread_; }; diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index a3ea7b27..a01ca924 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -13,8 +13,7 @@ waybar::modules::Custom::Custom(const std::string& name, const std::string& id, tooltip_format_enabled_{config_["tooltip-format"].isString()}, percentage_(0), fp_(nullptr), - pid_(-1), - signal_(config_["signal"].isInt() ? config_["signal"].asInt() : -1) { + pid_(-1) { if (config.isNull()) { spdlog::warn("There is no configuration for 'custom/{}', element will be hidden", name); } @@ -137,7 +136,7 @@ void waybar::modules::Custom::waitingWorker() { } void waybar::modules::Custom::refresh(int sig) { - if (signal_ != -1 && sig == SIGRTMIN + signal_) { + if (config_["signal"].isInt() && sig == SIGRTMIN + config_["signal"].asInt()) { thread_.wake_up(); } } diff --git a/src/modules/image.cpp b/src/modules/image.cpp index 4e830608..189deee6 100644 --- a/src/modules/image.cpp +++ b/src/modules/image.cpp @@ -1,9 +1,7 @@ #include "modules/image.hpp" waybar::modules::Image::Image(const std::string& id, const Json::Value& config) - : AModule(config, "image", id), - box_(Gtk::ORIENTATION_HORIZONTAL, 0), - signal_(config_["signal"].isInt() ? config_["signal"].asInt() : -1) { + : AModule(config, "image", id), box_(Gtk::ORIENTATION_HORIZONTAL, 0) { box_.pack_start(image_); box_.set_name("image"); if (!id.empty()) { @@ -43,7 +41,7 @@ void waybar::modules::Image::delayWorker() { } void waybar::modules::Image::refresh(int sig) { - if (signal_ != -1 && sig == SIGRTMIN + signal_) { + if (config_["signal"].isInt() && sig == SIGRTMIN + config_["signal"].asInt()) { thread_.wake_up(); } }