mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
The mutexes in PIDControllerRunner are declared after the Notifier, and when the PIDControllerRunner object is destructed, the member object destructors are called in the reverse order in which they are declared. The mutexes are destructed first, then the Notifier destructor is called which stops the Notifier. There's a window between those destructor calls during which the Notifier can run the callable and attempt to lock a mutex that no longer exists. Declaring the Notifier after all the variables its callable uses fixes this issue, as it ensures the Notifier is destructed first.