Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sched: fix race start_early_threads()
In issue #145 I reported a crash during boot in start_early_threads(). I wasn't actually able to replicate this bug on master, but it happens quite frequently (e.g., on virtually every "make check" run) with some patches of mine that seem unrelated to this bug. The problem is that start_early_threads() (added in 63216e8) iterates on the threads in the thread list, and uses t->remote_thread_local_var() for each thread. This can only work if the thread has its TLS initialized, but unfortunately in thread's constructor we first added the new thread to the list, and only later called setup_tcb() (which allocates and initializes the TLS). If we're unlucky, start_early_threads() can find a thread on the list which still doesn't have its TLS allocated, so remote_thread_local_var() will crash. The simple fix is to switch the order of the construction: First set up the new thread's TLS, and only then add it to the list of threads. Fixes #145. Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
- Loading branch information