It's possible that this code may appear to work if you are using an Apache MPM such as worker
which uses threads heavily, since all of the threads will share an address space with each other, as well as with their parent process. However, it will not work under heavy load (as Apache will start to use different processes for each set of threads), or at all under the prefork
mpm.
If you want to store data in shared memory, all of the data must be stored in shared memory (i.e, you cannot use malloc()
for any of it), and you cannot use pointers within that memory (since they will become invalid if the shm region is mapped to a different location).