From 9af41ca61a7a5219b3e43d356bd307bccd5acc30 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 13 May 2016 00:56:42 +0200 Subject: [PATCH 1/2] Eliminates a race condition accessing DBusBabysitter instance at startup of babysitter() on Windows. Ensure that the babysitter thread already owns its one reference to the babysitter when it starts up, and eliminates the race condition. This patch requires that DBusBabysitter refcounting is thread-safe and is based on an analysis and proposal of Simon Mc Vittie. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95191 --- dbus/dbus-spawn-win.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index 58f0d77..493b556 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -601,8 +601,6 @@ babysitter (void *parameter) DBusBabysitter *sitter = (DBusBabysitter *) parameter; PING(); - _dbus_babysitter_ref (sitter); - _dbus_verbose ("babysitter: spawning %s\n", sitter->log_name); PING(); @@ -732,7 +730,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, PING(); sitter_thread = (HANDLE) CreateThread (NULL, 0, babysitter, - sitter, 0, &sitter_thread_id); + _dbus_babysitter_ref (sitter), 0, &sitter_thread_id); if (sitter_thread == 0) { -- 2.6.6