Fix issue 732 semaphore exceptions #766
Open
Hatem-707 wants to merge 2 commits intotaskflow:masterfrom
Open
Conversation
Contributor
Author
SummaryI changed the way i check for exceptions when attempting to acquire semaphores to avoid accessing the node pointer which might have moved to the semaphore queue. Also update the second test I added to allow exclusive access to the variable captured by reference. Testingthe changes were tested with the compile flag -fsanitize=thread using clang on an arch system and passed all unittests with no warnings. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#732
Summary:
I have added a DFS recursive method , _handle_broken_semaphores, to the tf::Node class to remove deadlocks that happen because of exceptions thrown down the chain. This is done via calling it on all preceding nodes stored in _edges vector. The method is similar to tf::Semaphore::_release taking a reference to a SmallVector of Node * and storing the waiter nodes' pointers so they can be rescheduled removing the deadlock. There's also an unordered set to handle loops. I also added a new state, _is_broken, to the tf::Semaphore class which prevents acquiring a semaphore that has had an exception until it's reset.
Tests and benchmarks:
Notes:
This is my first time contributing and I would welcome any kind of feedback and I am open to adding more test/ documentation to my changes.