7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 23:21:41 +00:00

Construction geom: thread must be constructed last

If the thread starts before the proposal tag is constructed
as nullopt, the thread can unblock and think it has a proposal.
This isn't true, so it reads junk memory and crashes.

Relates-To: https://gitlab.com/kicad/code/kicad/-/issues/18835
This commit is contained in:
John Beard 2024-10-27 07:39:08 +08:00
parent 4846d07e47
commit f09d274a3e

View File

@ -146,12 +146,6 @@ private:
// Activation timeout in milliseconds
std::chrono::milliseconds m_timeout;
///< Callback to call when the proposal is accepted
ACTIVATION_CALLBACK m_callback;
std::condition_variable m_cv;
std::atomic<bool> m_stop;
std::thread m_thread;
std::chrono::time_point<std::chrono::steady_clock> m_proposalDeadline;
///< The last proposal tag that was made
@ -162,6 +156,13 @@ private:
// The most recently-proposed item
T m_lastProposal;
///< Callback to call when the proposal is accepted
ACTIVATION_CALLBACK m_callback;
std::condition_variable m_cv;
std::atomic<bool> m_stop;
// The thread must be constructed last, as it starts running immediately
std::thread m_thread;
};