iox-#2440 Fix race condition that can cause failed chunk management a…#2443
Conversation
931c73f to
0d95da3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2443 +/- ##
==========================================
- Coverage 78.26% 78.26% -0.01%
==========================================
Files 445 445
Lines 17091 17093 +2
Branches 2373 2373
==========================================
+ Hits 13376 13377 +1
Misses 2835 2835
- Partials 880 881 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@elBoberido I noticed there is no protection around the I can also change I can ALSO qualify that method as |
33ee77e to
b679df1
Compare
|
@elBoberido ready for re-review |
b679df1 to
6e9ef92
Compare
|
@gpalmer-latai |
6e9ef92 to
2604c4f
Compare
|
|
||
| // Here the chunk management must be freed before the chunk itself to maintain | ||
| // the invariant that there are always at least as many chunk management chunks available as payload chunks | ||
| chunkManagement.m_chunkManagementPool->freeChunk(&chunkManagement); |
There was a problem hiding this comment.
Hehe, I was also thinking about proposing this but then I thought it might be a bad idea since the reference becomes dangling after calling freeChunk and there is now way to indicate it. With the pointer, one could just set it to a nullptr.
Unfortunately, the language does not give us good options.
Not suggesting to change it but would be good to know your thought process on this.
What do you think of adding a comment right below this line, like // NOTE: chunkManagement is dangling from here on?
There was a problem hiding this comment.
Hmmmm... Maybe we should just rewrite Iceoryx in Rust? 😆
Sure, I'll add a comment just to be extra cautious.
There was a problem hiding this comment.
yeah, but how shall we call it? riceoryx?
cc @elfenpiff a lost opportunity but it's maybe not too late
…nk management allocation Signed-off-by: Graham Palmer <gpalmer+github@lat.ai>
2604c4f to
9baed66
Compare
…llocation
Notes for Reviewer
As described in #2440, the race condition exists between the
MemoryManageracquiring chunks for payloads before acquiring chunks for management, and theSharedChunkreleasing chunks for payloads before releasing chunks for management.The
MemoryManagerrelies upon the assumption that if a payload allocation succeeded, the management allocation will succeed. This assumption proves to be false however for a brief moment whenSharedChunk::releaseChunkreleases the payload chunk but has not yet released the management chunk.The changes in this pull request resolve the issue by switching the order of release such that the management chunk is released before the payload chunk. This properly uploads the invariant that the number of management chunks is always greater than or equal to the number of payload chunks - since for any given payload/management pair the lifetime of the management chunk is contained within the lifetime of the payload chunk.
With regards to testing - there isn't any formal way to prove these changes resolve the issue nor prevent a new issue, other than running the stress tests.
Pre-Review Checklist for the PR Author
iox-123-this-is-a-branch)iox-#123 commit text)task-list-completed)Checklist for the PR Reviewer
iceoryx_hoofshave been added to./clang-tidy-diff-scans.txtPost-review Checklist for the PR Author
References