From 2f7e421eed33bda89820d3da5e191e27e8fe0e06 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Tue, 26 Jun 2018 12:01:51 +0200 Subject: [PATCH] linux: destroy native CPU client after thread start The native CPU client holds a capability reference and the reference counter of the capability can reach its limit when many threads are successively created and destroyed (destroyed by the Linux kernel). Fixes #2886 --- repos/base-linux/src/lib/base/thread_linux.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/repos/base-linux/src/lib/base/thread_linux.cc b/repos/base-linux/src/lib/base/thread_linux.cc index 69773f1dee..950848c7eb 100644 --- a/repos/base-linux/src/lib/base/thread_linux.cc +++ b/repos/base-linux/src/lib/base/thread_linux.cc @@ -68,8 +68,10 @@ void Thread::_thread_start() lx_sigaction(LX_SIGUSR1, empty_signal_handler, false); /* inform core about the new thread and process ID of the new thread */ - Linux_native_cpu_client native_cpu(thread->_cpu_session->native_cpu()); - native_cpu.thread_id(thread->cap(), thread->native_thread().pid, thread->native_thread().tid); + { + Linux_native_cpu_client native_cpu(thread->_cpu_session->native_cpu()); + native_cpu.thread_id(thread->cap(), thread->native_thread().pid, thread->native_thread().tid); + } /* wakeup 'start' function */ startup_lock().unlock();