[systemd/f16] Fix a crash related to pid file watch and daemon-reload (#783118)

Michal Schmidt michich at fedoraproject.org
Fri Jan 20 01:16:08 UTC 2012


commit 83ed7924676cfdb289cce4c5fbba0e62e7a17e3c
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Fri Jan 20 01:56:20 2012 +0100

    Fix a crash related to pid file watch and daemon-reload (#783118)

 ...-missing-pid-file-unwatch-in-the-destruct.patch |   81 ++++++++++++++++++++
 systemd.spec                                       |    6 +-
 2 files changed, 86 insertions(+), 1 deletions(-)
---
diff --git a/0132-service-add-missing-pid-file-unwatch-in-the-destruct.patch b/0132-service-add-missing-pid-file-unwatch-in-the-destruct.patch
new file mode 100644
index 0000000..0024ad1
--- /dev/null
+++ b/0132-service-add-missing-pid-file-unwatch-in-the-destruct.patch
@@ -0,0 +1,81 @@
+From b56feb27b829f7babd41dfa610d191ddf1c9aa03 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Thu, 19 Jan 2012 23:58:07 +0100
+Subject: [PATCH] service: add missing pid file unwatch in the destructor
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The pid file watch could outlive the service unit if a daemon-reload
+request came at the right time. The inotify event would then be
+delivered to who knows where.
+
+Fix it by unwatching in the service destructor.
+
+Further changes will be needed to preserve the state of the pid file
+watch across daemon-reload. For now let's just fix the crash observed
+by Jóhann Guðmundsson:
+Assertion 's->state == SERVICE_START || s->state == SERVICE_START_POST'
+failed at src/service.c:2609, function service_fd_event().  Aborting
+
+Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=783118
+(cherry picked from commit 3e52541ef51b1004357fbcd4bf863fb955ab83e9)
+
+Conflicts:
+
+	src/service.c
+---
+ src/service.c |   23 ++++++++++++-----------
+ 1 files changed, 12 insertions(+), 11 deletions(-)
+
+diff --git a/src/service.c b/src/service.c
+index 81a2954..f99ee60 100644
+--- a/src/service.c
++++ b/src/service.c
+@@ -147,6 +147,17 @@ static void service_unwatch_main_pid(Service *s) {
+         s->main_pid = 0;
+ }
+ 
++static void service_unwatch_pid_file(Service *s) {
++        if (!s->pid_file_pathspec)
++                return;
++
++        log_debug("Stopping watch for %s's PID file %s", s->meta.id, s->pid_file_pathspec->path);
++        path_spec_unwatch(s->pid_file_pathspec, UNIT(s));
++        path_spec_done(s->pid_file_pathspec);
++        free(s->pid_file_pathspec);
++        s->pid_file_pathspec = NULL;
++}
++
+ static int service_set_main_pid(Service *s, pid_t pid) {
+         pid_t ppid;
+ 
+@@ -222,6 +233,7 @@ static void service_done(Unit *u) {
+          * our resources */
+         service_unwatch_main_pid(s);
+         service_unwatch_control_pid(s);
++        service_unwatch_pid_file(s);
+ 
+         if (s->bus_name)  {
+                 unit_unwatch_bus_name(UNIT(u), s->bus_name);
+@@ -1381,17 +1393,6 @@ static void service_notify_sockets_dead(Service *s) {
+         return;
+ }
+ 
+-static void service_unwatch_pid_file(Service *s) {
+-        if (!s->pid_file_pathspec)
+-                return;
+-
+-        log_debug("Stopping watch for %s's PID file %s", s->meta.id, s->pid_file_pathspec->path);
+-        path_spec_unwatch(s->pid_file_pathspec, UNIT(s));
+-        path_spec_done(s->pid_file_pathspec);
+-        free(s->pid_file_pathspec);
+-        s->pid_file_pathspec = NULL;
+-}
+-
+ static void service_set_state(Service *s, ServiceState state) {
+         ServiceState old_state;
+         assert(s);
+-- 
+1.7.7.5
+
diff --git a/systemd.spec b/systemd.spec
index f6538ae..eb4ed6c 100644
--- a/systemd.spec
+++ b/systemd.spec
@@ -2,7 +2,7 @@ Name:           systemd
 Url:            http://www.freedesktop.org/wiki/Software/systemd
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Version:        37
-Release:        8%{?dist}
+Release:        9%{?dist}
 License:        GPLv2+
 Group:          System Environment/Base
 Summary:        A System and Service Manager
@@ -179,6 +179,7 @@ Patch0128:      0128-pam-work-correctly-if-a-seat-is-specified-but-not-vt.patch
 Patch0129:      0129-pam-fix-build.patch
 Patch0130:      0130-mount-fix-quota.patch
 Patch0131:      0131-logind-downgrade-login-message-to-debug.patch
+Patch0132:      0132-service-add-missing-pid-file-unwatch-in-the-destruct.patch
 
 # For sysvinit tools
 Obsoletes:      SysVinit < 2.86-24, sysvinit < 2.86-24
@@ -497,6 +498,9 @@ fi
 %{_bindir}/systemd-sysv-convert
 
 %changelog
+* Fri Jan 20 2012 Michal Schmidt <mschmidt at redhat.com> - 37-9
+- Fix a crash related to pid file watch and daemon-reload (#783118).
+
 * Tue Jan 17 2012 Michal Schmidt <mschmidt at redhat.com> - 37-8
 - Shut up another logind message (#727315).
 


More information about the scm-commits mailing list