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

[#116] Fix race in shm create or open #124

Conversation

elfenpiff
Copy link
Contributor

@elfenpiff elfenpiff commented Feb 19, 2024

Notes for Reviewer

Fixes race in posix::SharedMemory.

  1. Two processes try to create or open a shared memory
  2. Both detect that none is available
  3. Both try to create a new one - only one will succeed, the other complains: shm does not exist and I cannot create a new one.

Solution: If create fails, try to reopen it.

Removes: retrieve buffer full check from zero copy sender. The sender does not have enough information available to determine if the buffer is really insufficient. It needs to know how many samples the subscriber has currently borrowed - an information only the receiver has.

Introduce memory sync in zero copy connection open procedure. When a zero copy connection is opened and the creation is still in progress, the opener will check the init_state until it is initialized. If it is signaling that the initialization is done, it will consume the contents - without memory sync. Adding acquire / release to sync the initialized memory with the other process.

Pre-Review Checklist for the PR Author

  1. Add sensible notes for the reviewer
  2. PR title is short, expressive and meaningful
  3. Relevant issues are linked
  4. Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
  5. Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  6. Commits messages are according to this guideline
  7. Tests follow the best practice for testing
  8. Changelog updated in the unreleased section including API breaking changes
  9. Assign PR to reviewer
  10. All checks have passed (except task-list-completed)

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

Relates to #116

@elfenpiff elfenpiff requested a review from elBoberido February 19, 2024 09:19
@elfenpiff elfenpiff self-assigned this Feb 19, 2024
Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (8ef4986) 77.39% compared to head (7b89058) 77.37%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
- Coverage   77.39%   77.37%   -0.03%     
==========================================
  Files         181      181              
  Lines       19615    19599      -16     
==========================================
- Hits        15181    15164      -17     
- Misses       4434     4435       +1     
Files Coverage Δ
iceoryx2-cal/src/zero_copy_connection/mod.rs 20.68% <ø> (ø)
...al/src/zero_copy_connection/posix_shared_memory.rs 89.71% <100.00%> (-0.21%) ⬇️
...ryx2-cal/src/zero_copy_connection/process_local.rs 92.30% <ø> (-0.18%) ⬇️
iceoryx2/src/port/publisher.rs 84.12% <100.00%> (+0.79%) ⬆️
iceoryx2-bb/posix/src/shared_memory.rs 81.23% <50.00%> (-0.43%) ⬇️

... and 1 file with indirect coverage changes

@elfenpiff elfenpiff force-pushed the iox2-116-fix-race-in-shm-create-or-open branch from a444ddd to 278a4c8 Compare February 19, 2024 09:54
elBoberido
elBoberido previously approved these changes Feb 19, 2024
doc/release-notes/iceoryx2-unreleased.md Outdated Show resolved Hide resolved
@elfenpiff elfenpiff force-pushed the iox2-116-fix-race-in-shm-create-or-open branch from 278a4c8 to 31fbb02 Compare February 19, 2024 12:03
@elfenpiff elfenpiff requested a review from elBoberido February 19, 2024 12:03
…n, remove retrieve buffer check from publisher - the publisher has not enough information to perform this check
@elfenpiff elfenpiff force-pushed the iox2-116-fix-race-in-shm-create-or-open branch from 31fbb02 to 7b89058 Compare February 19, 2024 13:14
@elfenpiff elfenpiff merged commit 80db0c4 into eclipse-iceoryx:main Feb 20, 2024
23 checks passed
@elfenpiff elfenpiff deleted the iox2-116-fix-race-in-shm-create-or-open branch February 20, 2024 06:41
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.

2 participants