In the notes for Patch E it states
CAUTION: The QNX 4 kernel does NOT maintain reference counts
on shared-memory fds. If you mmap a pointer to your application, don’t
close the fd and then shmem_unlink the memory object and continue to
reference that memory object through the pointer.
" For example, here are the incorrect and correct forms:
Incorrect form:
fd = shmem_open(“memory”…);
ptr = mmap(…);
shmem_unlink(“memory”);
close(fd);
modify data at ptr
Correct form:
fd = shmem_open(“memory”…);
ptr = mmap(…);
shmem_unlink(“memory”);
modify data at ptr
If you don’t use the correct form, the memory that your ptr refers to
could be given back to the OS for other allocation. As a result, you
could end up writing into memory regions owned by another process,
thus causing that other process to fail."
I took a look at how we have done this for shared memory and I am a bit
confused.
We are doing it in this manner
fd = shmem_open(“memory”…);
ptr = mmap(…);
close(fd);
modify data at ptr
This is in a library routine called by several apps to get the sharted
memory pointer.
My question is are we causing problems doing this? Should be call
shmem_unlink
instead of close? TIA.
\
Ivan Bannon
RJG Inc.