[MainLoop] Fix possible use of an invalid iterator
authorPetr Pavlu <petr.pavlu@arm.com>
Wed, 12 Jul 2017 12:38:31 +0000 (12:38 +0000)
committerPetr Pavlu <petr.pavlu@arm.com>
Wed, 12 Jul 2017 12:38:31 +0000 (12:38 +0000)
commit8c5dafde494fd63bfa4ca58b1919936fdd5204e8
tree33ac421698e38b667d1149d17fb10e3818780a46
parent293b4fc04e6a49667ee878b6f252cc68c42fa385
[MainLoop] Fix possible use of an invalid iterator

Store file descriptors from loop.m_read_fds (if FORCE_PSELECT is
defined) and signals from loop.m_signals that need to be processed in
MainLoop::RunImpl::ProcessEvents() into a separate vector and then
iterate over this container to invoke the callbacks.

This prevents a problem where when the code iterated directly over
m_read_fds/m_signals, a callback invoked from within the loop could
modify these variables and invalidate the loop iterator. This would then
result in an assertion failure in llvm::DenseMapIterator::operator++().

Differential Revision: https://reviews.llvm.org/D35298

llvm-svn: 307782
lldb/source/Host/common/MainLoop.cpp