Change ThreadPlanStack::PopPlan and ::DiscardPlan to not do the following:
- Move the last plan, leaving a moved ThreadPlanSP in the plans vector
- Call out to WillPop which can't guarantee that m_plans isn't accessed in its invalid state
- Pop the last plan off the plans vector
This leaves a period of time where the last element in the plans vector has been moved, leaving a null ThreadPlanSP in the container. There are asserts in place to prevent null ThreadPlanSP instances from being pushed on to the stack, and so this could break that invariant.
From discussion, it seems the use of std::move wasn't the result of a measured performance problem.
Should we comment that we are intentionally making a copy of the SP to avoid a race condition with std::move()?