|
|
5edf9f4 |
From 18989faac5138213a99f63346e49f4279caad9fb Mon Sep 17 00:00:00 2001
|
|
|
5edf9f4 |
From: Colin Ian King <colin.king@canonical.com>
|
|
|
5edf9f4 |
Date: Thu, 20 Apr 2017 18:40:47 +0100
|
|
|
5edf9f4 |
Subject: [PATCH] Don't terminate the thermald engine if thd_engine is null
|
|
|
5edf9f4 |
|
|
|
5edf9f4 |
It is possible for a signal to occur before the thermald engine
|
|
|
5edf9f4 |
is up and running and hence trying to call the terminate method
|
|
|
5edf9f4 |
will result in a segmentation fault. Check to see if thd_engine
|
|
|
5edf9f4 |
is non-null before invoking thd_engine_terminate.
|
|
|
5edf9f4 |
|
|
|
5edf9f4 |
Fixes bug http://bugs.launchpad.net/bugs/1677427
|
|
|
5edf9f4 |
|
|
|
5edf9f4 |
Note: I was able to reproduce the bug by inserting a
|
|
|
5edf9f4 |
kill(getpid(), SIGTERM) after the signal handler was installed
|
|
|
5edf9f4 |
and before the thermald engine is started to reliably trip the
|
|
|
5edf9f4 |
issue. There is just a very small window where this bug can
|
|
|
5edf9f4 |
actually can occur.
|
|
|
5edf9f4 |
|
|
|
5edf9f4 |
Signed-off-by: Colin Ian King <colin.king@canonical.com>
|
|
|
5edf9f4 |
---
|
|
|
5edf9f4 |
src/main.cpp | 3 ++-
|
|
|
5edf9f4 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
5edf9f4 |
|
|
|
5edf9f4 |
diff --git a/src/main.cpp b/src/main.cpp
|
|
|
5edf9f4 |
index 14bd912..36abe7b 100644
|
|
|
5edf9f4 |
--- a/src/main.cpp
|
|
|
5edf9f4 |
+++ b/src/main.cpp
|
|
|
5edf9f4 |
@@ -137,7 +137,8 @@ bool check_thermald_running() {
|
|
|
5edf9f4 |
|
|
|
5edf9f4 |
// SIGTERM & SIGINT handler
|
|
|
5edf9f4 |
void sig_int_handler(int signum) {
|
|
|
5edf9f4 |
- thd_engine->thd_engine_terminate();
|
|
|
5edf9f4 |
+ if (thd_engine)
|
|
|
5edf9f4 |
+ thd_engine->thd_engine_terminate();
|
|
|
5edf9f4 |
sleep(1);
|
|
|
5edf9f4 |
if (g_main_loop)
|
|
|
5edf9f4 |
g_main_loop_quit(g_main_loop);
|