]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: tasks: don't requeue global tasks into the local queue
authorWilly Tarreau <w@1wt.eu>
Wed, 22 Jul 2020 12:12:45 +0000 (14:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 22 Jul 2020 12:12:45 +0000 (14:12 +0200)
A bug was introduced by commit 77015abe0 ("MEDIUM: tasks: clean up the
front side of the wait queue in wake_expired_tasks()"): front tasks
that are not yet expired were incorrectly requeued into the local
wait queue instead of the global one. Because of this, the same task
could be found by the same thread on next invocation and be unlinked
without locking, allowing another thread to requeue it in parallel,
and conversely another thread could unlink it while the task was being
walked over, causing all sorts of crashes and endless loops in
wake_expired_tasks() and affiliates.

This bug can easily be triggered by stressing the do_resolve action
in multi-thread (after applying the fixes required to get do_resolve
to work with threads). It certainly is the cause of issue #758.

This must be backported to 2.2 only.

src/task.c

index 1a924c18c0a94ff891747c485324165b50398d88..449857806dbd3356d4213732d2f4f5e3c8ffcdd1 100644 (file)
@@ -315,7 +315,7 @@ void wake_expired_tasks()
                         */
                        __task_unlink_wq(task);
                        if (tick_isset(task->expire))
-                               __task_queue(task, &tt->timers);
+                               __task_queue(task, &timers);
                        goto lookup_next;
                }
                else {