Skip to content

Use anonymous shared memory - #867

Open
WilliamRoebuck wants to merge 3 commits into
eclipse-score:mainfrom
etas-contrib:feature/anon-shared-mem
Open

WilliamRoebuck wants to merge 3 commits into
eclipse-score:mainfrom
etas-contrib:feature/anon-shared-mem

Conversation

@WilliamRoebuck

Copy link
Copy Markdown
Contributor

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_create and QNX the O_ANON flag to create shared memory without depending on a name.
Added osal function shm_open_anon to use the correct method for each OS.

@WilliamRoebuck
WilliamRoebuck force-pushed the feature/anon-shared-mem branch from 6c02613 to b5d753f Compare October 27, 2026 10:07
@WilliamRoebuck
WilliamRoebuck deployed to workflow-approval October 27, 2026 10:08 — with GitHub Actions Active
@WilliamRoebuck
WilliamRoebuck deployed to workflow-approval October 27, 2026 10:08 — with GitHub Actions Active
@WilliamRoebuck
WilliamRoebuck deployed to workflow-approval October 27, 2026 10:08 — with GitHub Actions Active
@WilliamRoebuck
WilliamRoebuck deployed to workflow-approval October 27, 2026 10:08 — with GitHub Actions Active
namespace score::mw::lifecycle::internal::osal
{

/// @brief Open an anonymous shared memory file with (M)FD_CLOEXEC.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
/// @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 "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Suggesting a less confusing name

Suggested change
shm_name = {"/ipc_shared_mem_OUTOFNUMBERS\0"};
shm_name = {"/ipc_shared_mem_generic_name\0"};

@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-867: https://eclipse-score.github.io/lifecycle/pr-867/

"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 "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 Linux memfd_create and QNX O_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

This branch was successfully deployed

1 active deployment
workflow-approval — b5d753fb Deployed Oct 27, 2026 by WilliamRoebuck via Build and test x86_64-qnx / approval #1830
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants