Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect phase switch from race conditions #111

Merged
merged 8 commits into from
Mar 19, 2024
Merged

Protect phase switch from race conditions #111

merged 8 commits into from
Mar 19, 2024

Conversation

mxgrey
Copy link
Contributor

@mxgrey mxgrey commented Mar 1, 2024

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.

mxgrey and others added 8 commits March 1, 2024 07:43
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Copy link
Member

@xiyuoh xiyuoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested it out over a period of time and the crashes have not resurfaced.

@xiyuoh xiyuoh merged commit 7cceafd into main Mar 19, 2024
5 checks passed
@xiyuoh xiyuoh deleted the safer_phase_switch branch March 19, 2024 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants