[Development] QSharedMemory POSIX implementation
Thiago Macieira
thiago.macieira at intel.com
Wed Jul 9 17:22:31 CEST 2014
On Wednesday 09 July 2014 16:17:38 Calogero Mauceri wrote:
> Hi all,
>
> I find QSharedMemory very useful, and I'm extensively using it for cross
> platform IPC.
>
> I noticed in the code (qsharedmemory_unix.cpp) there are two
> implementations for that class, one using System V IPC and the other
> using POSIX IPC (mmap). On both Linux and Mac versions of Qt, the System
> V primitives are used and there is no way to compile Qt using the POSIX
> implementation (-posix-ipc option is not available in configure).
>
> Is there any reason why the System V implementation is preferred? I'd
> like to switch to the POSIX one to overcome limits in some platforms
> where the maximum shared memory allowed is only 4MB.
Warning: here there be dragons.
That code path has probably not been compiled in years. Just patch your Qt to
enable it.
Note that POSIX memory sharing like that runs a huge risk. Never accept shared
memory segments from untrusted applications, since they can crash you: all you
need to do is use a file-backed segment of memory (as opposed to anonymous
mmap) and then shrink the file. Linux is getting an extension to prevent that,
called memory sealing, but I'm guessing Linux isn't your problem OS.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list