eclipse-iceoryx / iceoryx2

Eclipse iceoryx2™ - true zero-copy inter-process-communication in pure Rust
https://iceoryx.io
Apache License 2.0
1.03k stars 40 forks source link

Clean initialization for dynamic storage #364

Open elfenpiff opened 2 months ago

elfenpiff commented 2 months ago

Overview

Currently, the initialization of the dynamic storage is handled by setting the permissions to write only during initialization and then adjust them to read/write after the initialization was completed. But, this approach only works for linux since FreeBSD, MacOs and Windows seem to be unable to adjust the permissions of the shared memory after it was created.

Every posix shared memory based dynamic storage also contains a version number to ensure that non-compatible versions are unable to connect. If the version number is zero it is also regarded as uninitialized. The problem is, that this is undefined behavior but works most of the time since the operating system zero's the memory before providing it to the application.

A cleaner approach would be to use the permissions again. FreeBSD and MacOs use a trampoline file to point to the correct shared memory, due to the name length limitations. Instead of adjusting the shared memory access rights, one could work with the access rights of the trampoline file which would offer a clean solution. On Windows we could implement a similar approach.

Details