Repository navigation
Use anonymous shared memory - #867
WilliamRoebuck wants to merge 3 commits into
Conversation
fdc6100 to
6c02613
Compare
6c02613 to
b5d753f
Compare
| namespace score::mw::lifecycle::internal::osal | ||
| { | ||
|
|
||
| /// @brief Open an anonymous shared memory file with (M)FD_CLOEXEC. |
There was a problem hiding this comment.
nit: MFD_CLOEXEC is only for QNX. Maybe just drop the "with (M)FD_CLOEXEC" from the comment? Could mention how it is platform specific.
| /// @brief Open an anonymous shared memory file with (M)FD_CLOEXEC. | |
| /// @brief Open an anonymous shared memory file using OS-dependent implementations. |
| "object name."; | ||
| return false; | ||
| // Anonymous shared mem name is only used for debugging (or discarded on QNX). It does not need to be unique | ||
| LM_LOG_INFO() << "Shared memory name truncated: the local buffer is too small for the shared memory " |
There was a problem hiding this comment.
Maybe a warning is more suitable?
| LM_LOG_INFO() << "Shared memory name truncated: the local buffer is too small for the shared memory " | ||
| "object name. Proceeding with generic name"; | ||
|
|
||
| shm_name = {"/ipc_shared_mem_OUTOFNUMBERS\0"}; |
There was a problem hiding this comment.
nit: Suggesting a less confusing name
| shm_name = {"/ipc_shared_mem_OUTOFNUMBERS\0"}; | |
| shm_name = {"/ipc_shared_mem_generic_name\0"}; |
|
Documentation preview for this pull request is available at: |
| "object name."; | ||
| return false; | ||
| // Anonymous shared mem name is only used for debugging (or discarded on QNX). It does not need to be unique | ||
| LM_LOG_INFO() << "Shared memory name truncated: the local buffer is too small for the shared memory " |
There was a problem hiding this comment.
Is this name building still needed? In shm_open_anon.hpp is says "multiple
/// files can have the same name without any side effect" so can every anonymous shared memory get the same name?
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the move to platform-specific anonymous shared memory.
No open issues 🎉
What changed in this PR
This PR moves launch-manager IPC allocation to platform-specific anonymous shared memory, avoiding failures caused by shared-memory name collisions.
Changes:
- Adds
shm_open_anon, using Linuxmemfd_createand QNXO_ANON. - Updates process launching to use the abstraction and tolerate debug-name truncation.
- Adjusts build dependencies, syscall mocks, and tests for anonymous shared memory.
| File | Description |
|---|---|
tests/utils/mocks/mock_syscalls.hpp |
Adds a mock for shm_open_anon. |
tests/integration/process_fd_leak/reporting.cpp |
Updates the expected descriptor path to Linux memfd format. |
tests/integration/process_fd_leak/control_client_test_driver.cpp |
Updates the expected descriptor path to Linux memfd format. |
score/launch_manager/src/daemon/src/process_group_manager/details/process_launcher.cpp |
Uses anonymous allocation and adds a fallback debug name. |
score/launch_manager/src/daemon/src/process_group_manager/details/process_launcher_UT.cpp |
Replaces named-memory mock expectations with shm_open_anon. |
score/launch_manager/src/daemon/src/process_group_manager/details/BUILD |
Adds the anonymous-memory library dependency. |
score/launch_manager/src/daemon/src/osal/shm_open_anon.hpp |
Declares and documents the anonymous-memory interface. |
score/launch_manager/src/daemon/src/osal/details/qnx/shm_open_anon.cpp |
Implements allocation using QNX O_ANON. |
score/launch_manager/src/daemon/src/osal/details/linux/shm_open_anon.cpp |
Implements allocation using Linux memfd_create. |
score/launch_manager/src/daemon/src/osal/BUILD |
Selects the platform-specific implementation. |
Review effort: Balanced
Currently, we create anonymous shared memory with
shm_open+shm_unlink. This can fail if the shared memory name is already in use.For anonymous shared memory, Linux provides
memfd_createand QNX theO_ANONflag to create shared memory without depending on a name.Added osal function
shm_open_anonto use the correct method for each OS.