We recently found a crash that seems to originate from the phase switching code in rmf_task_sequence. While it's still unclear what conditions could have caused the crash, the most likely culprit would be a race condition.
This PR adds a mutex that locks before any phase switching happens, which should ensure that race conditions cannot lead to a crash happening. We also add some sanity checks that run each time a phase switch is set to happen, so if anything suspicious is going on we'll identify it before a segmentation fault can happen. Unfortunately those situations cause us to abort via exception, but that is likely a better outcome than allowing undefined behavior to proceed.
We recently found a crash that seems to originate from the phase switching code in
rmf_task_sequence
. While it's still unclear what conditions could have caused the crash, the most likely culprit would be a race condition.This PR adds a mutex that locks before any phase switching happens, which should ensure that race conditions cannot lead to a crash happening. We also add some sanity checks that run each time a phase switch is set to happen, so if anything suspicious is going on we'll identify it before a segmentation fault can happen. Unfortunately those situations cause us to abort via exception, but that is likely a better outcome than allowing undefined behavior to proceed.