btzy / circuit-sandbox

GNU General Public License v3.0
3 stars 1 forks source link

Clipboards on POSIX may not persist properly #43

Open btzy opened 6 years ago

btzy commented 6 years ago
  1. Open an instance of Circuit Sandbox.
  2. Write to a clipboard.
  3. Open another instance of Circuit Sandbox.
  4. Close the first instance.
  5. Open another instance of Circuit Sandbox. This new instance might not be able to read the data saved by the first instance.

See how Boost.Interprocess and shm_unlink works.

btzy commented 6 years ago

6c5f04b1e8309a945078e23f0b42dcd952b46fdb introduces reference counting for the POSIX shared memory. It fixes the bug for the sequence of actions above, and it works as intended as long as Circuit Sandbox does not crash or exit in an abnormal manner. If it crashes or exits abnormally, the reference count will not be decremented and the shared memory will not be removed until the system is rebooted (because POSIX shared memory has kernel persistence).