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
The actual concept is affected by it but does not require change, since the algorithm is correct but the platform does not support the permission initialization strategy.
The platform needs to support permission adjustments of shared memory after the shared memory was created.
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