Qt - QSharedMemory qipc files location

268 Views Asked by At

On Linux, Qt creates the following files in the /tmp directory when using QSharedMemory:

qipc_sharedmemory_mysharedmem5ffa537fd8798875c98e190df289da7e047c05
qipc_systemsem_mysharedmem5ffa537fd8798875c98e190df289da7e047c05

I have come across a problem where two different versions of the same software use two different locations for these files, making them incompatible. The "newer" version instead creates these files in the /tmp/username/ directory. I can't seem to figure out what causes this. Is this location defined by Qt itself, and if so, did it change across versions? Or can it somehow be configured by the user, and if so, where and how?

1

There are 1 best solutions below

0
Sergio Monteleone On

I think you are experiencing a known Qt bug, as reported in the official bug tracker here: https://bugreports.qt.io/browse/QTBUG-60771

Briefly, there was a change between Qt 5.6 and Qt 5.8 in the way QSystemSemaphore (which is used by QSharedMemory) creates its keys. It was discovered that the method used to create the keys may cause collisions.

The incompatibility is documented in the changelog for Qt 5.9 here: https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.9.0/?h=v5.9.0

[QTBUG-60771] Reverted a change that caused Qt 5.6 through 5.8 not to
   connect to QSystemSemaphore and QSharedMemory created by running
   applications using Qt earlier than 5.6. Unfortunately, this means that Qt
   5.9 will not connect to 5.6-5.8.

You may experiment with the QSharedMemory::setNativeKey() method to force your own keys (and thus, file names in the /tmp directory). Although this means you should modify and recompile both versions of your software.

I'm afraid the "official" solution is to ensure you only use one version of Qt at the time.