fix: tooldata mutex init - give before try#3832
Open
smoe wants to merge 1 commit intoLinuxCNC:2.9from
Open
Conversation
explicitly initialize the mutex, instead of calling tool_mmap_mutex_give() without a prior lock. Mutex is “given” without an initial successful “try/get” In src/emc/tooldata/tooldata_mmap.cc:163, tool_mmap_creator() calls tool_mmap_mutex_give() right after setup without any prior lock acquisition. That is unusual and potentially undefined depending on rtapi_mutex semantics.
Contributor
|
This is a mutex that can be "given" when not held. That said, the solution is not to remove the mutex give, but to add the mutex get in line 157 to protect the actual block that needs protecting. |
Contributor
|
Strike my last... You should just leave it as is. The 'give' actually initializes the mutex. Is simple clears the mutex unconditionally because you do not need to hold it to run 'give' on it. |
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.
explicitly initialize the mutex, instead of calling tool_mmap_mutex_give() without a prior lock.
Mutex is “given” without an initial successful “try/get” In src/emc/tooldata/tooldata_mmap.cc:163, tool_mmap_creator() calls tool_mmap_mutex_give() right after setup without any prior lock acquisition. According to the man page this is unusual and potentially undefined depending on rtapi_mutex semantics.
I am not sure about how much of a bug this is, but there should be an initial assignment of mutex, right?