[systemd-devel] [PATCH] core: do not spawn jobs or touch other units during coldplugging

Ivan Shapovalov intelfx100 at gmail.com
Tue Feb 24 12:14:51 PST 2015


On 2015-02-24 at 22:57 +0300, Ivan Shapovalov wrote:
> Because the order of coldplugging is not defined, we can reference a
> not-yet-coldplugged unit and read its state while it has not yet been
> set to a meaningful value.
> 
> This way, already active units may get started again.
> 
> Fixes https://bugs.freedesktop.org/show_bug.cgi?id=88401
> ---
> 
> I'm unsure whether I've done all this correctly. At least it seems that there
> are no leaks, and it survives the "while :; do systemctl daemon-reload & done"
> test.
> 
>  [...]

And here is a "reproducer" patch.
It makes all *.path units coldplugged before anything else.
You need to have at least one *.path unit started and "running"
(so that it will try to start the triggering unit immediately
during coldplug, and the bug will manifest itself).

The patch is against the unfixed tree. It conflicts with the actual fix,
but well...

diff --git a/src/core/manager.c b/src/core/manager.c
index 6382400..b5c4ed8 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -980,6 +980,26 @@ static int manager_coldplug(Manager *m) {
                 if (u->id != k)
                         continue;
 
+                /* we need a reproducer */
+                if (!endswith(u->id, ".path"))
+                        continue;
+
+                q = unit_coldplug(u);
+                if (q < 0)
+                        r = q;
+        }
+
+        HASHMAP_FOREACH_KEY(u, k, m->units, i) {
+                int q;
+
+                /* ignore aliases */
+                if (u->id != k)
+                        continue;
+
+                /* already processed them */
+                if (endswith(u->id, ".path"))
+                        continue;
+
                 q = unit_coldplug(u);
                 if (q < 0)
                         r = q;

-- 
Ivan Shapovalov / intelfx /

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150224/920c9536/attachment.sig>


More information about the systemd-devel mailing list