This repository was archived by the owner on Feb 3, 2023. It is now read-only.
CrossplatformThread double delete#453
Merged
Merged
Conversation
Octogonapus
approved these changes
Aug 13, 2020
Member
Octogonapus
left a comment
There was a problem hiding this comment.
Segfaults are bad
I won't argue against this one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
When a task callback returns, it looks like RTOS deletes the task. Therefore, when a
CrossplatformThreadis destructed, and the task callback has already returned, it is deleting an already deleted task. This causes a segfault.Motivation
Segfaults are bad, though I think this situation is fairly rare: a short-lived task being held by a CrossPlatformThread that will be destructed before program end.
Possible Drawbacks
It's possible that
STATE_INVALIDmight also need to be checked on, but I don't think so.Verification Process
This causes the unit tests in my own code to pass and not segfault. This is only reproducible on the V5 brain, std::threads behave better when double deleted (or they aren't deleted when the callback ends).
Otherwise my code works fine and CrossplatformThread still works.
Example
This segfaults: