diff options
author | jade <lix@jade.fyi> | 2024-10-15 00:11:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@localhost> | 2024-10-15 00:11:59 +0000 |
commit | f6077314fa6aff862758095bb55fe844e9162a1d (patch) | |
tree | b024107ad17f54044faf23cf31ba1d304b82ff18 /src/libutil/thread-pool.cc | |
parent | fbf7a8b4405610368c6d2bd12ff369fefa94f7a7 (diff) | |
parent | a0fb52c0af7b237e455c08689495e7c893a65ce8 (diff) |
Merge "Fix std::terminate call in thread pool" into main
Diffstat (limited to 'src/libutil/thread-pool.cc')
-rw-r--r-- | src/libutil/thread-pool.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/libutil/thread-pool.cc b/src/libutil/thread-pool.cc index cd380b608..1c4488373 100644 --- a/src/libutil/thread-pool.cc +++ b/src/libutil/thread-pool.cc @@ -109,8 +109,21 @@ void ThreadPool::doWork(bool mainThread) try { std::rethrow_exception(exc); } catch (std::exception & e) { - if (!dynamic_cast<ThreadPoolShutDown*>(&e)) - ignoreExceptionExceptInterrupt(); + if (!dynamic_cast<ThreadPoolShutDown*>(&e)) { + // Yes, this is not a destructor, but we cannot + // safely propagate an exception out of here. + // + // What happens is that if we do, shutdown() + // will have join() throw an exception if we + // are on a worker thread, preventing us from + // joining the rest of the threads. Although we + // could make the joining eat exceptions too, + // we could just as well not let Interrupted + // fall out to begin with, since the thread + // will immediately cleanly quit because of + // quit == true anyway. + ignoreExceptionInDestructor(); + } } catch (...) { } } |