[Lldb-commits] [lldb] [lldb] Print a message when background tasks take a while to complete (PR #82799)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 23 10:34:19 PST 2024
================
@@ -623,8 +630,20 @@ void Debugger::Terminate() {
}
if (g_thread_pool) {
- // The destructor will wait for all the threads to complete.
- delete g_thread_pool;
+ // Delete the thread pool in a different thread so we can set a timeout.
----------------
JDevlieghere wrote:
> Or is it too late and no one would receive events?
Yup, that's exactly the problem. The debugger has already been destroyed at this point, otherwise I could've written to the debugger's output stream. By the time we terminate, there's pretty much nothing left at this point. Before I had the callback I just wrote to stderr directly, but that's not a very nice thing to do as a library.
> Another option would be to have the thread pool detach from all threads so that we don't need to wait until they complete and just go ahead and exit?
That's what we did in the past and that caused a bunch of crashes. If you want to do that without crashing, you need to be very careful about what you do in a task running on the thread pool, because the debugger might have been destroyed and terminated while you were running.
https://github.com/llvm/llvm-project/pull/82799
More information about the lldb-commits
mailing list