Multi-process synchronization on Windows broken when one process exits or crashes

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: Core
    • None

      Currently our Multi-process synchronization on Windows is broken when one of the processes exits or crashes. My investigation shows the first process releases the semaphore here
      https://github.com/realm/realm-core/blob/dfd5baae3c2d1a6745bcf3a186fa5ba2f3069840/src/realm/util/interprocess_condvar.cpp#L484
      and goes and waits for WaitForSingleObject(m_waiters_done which will be signaled only if both processes are able to complete the logic in
      https://github.com/realm/realm-core/blob/dfd5baae3c2d1a6745bcf3a186fa5ba2f3069840/src/realm/util/interprocess_condvar.cpp#L310-L315

      which if the second process has crashed or exited will never happen.

      This leaves the first process hanging on the WaitForSingleObject(m_waiters_done indefinitely

      This is pretty reproducible in Electron when if the user closes the window it actually closes the renderer process responsible for that window and the main process of the application is left hanging.

            Assignee:
            Mathias Stearn
            Reporter:
            Lubo Blagoev
            Archiver:
            Marc Greenfield

              Created:
              Updated:
              Resolved:
              Archived: