juce::InterProcessLock not entering the lock


One of our software users has come across an issue after what it seems to be an application crash, and right after that, the software is never able to enter an interprocess lock, which we define and use as follows:

// defined as a static class member
static juce::InterProcessLock sIpcMutex("myOwnApplicationLock");

while (!sIpcMutex.enter(2000))
    // this loops would never end

This is happening on Windows (will soon confirm the version) and even after restarting the machine.

Any ideas why this may happen?


Interprocess locks are generally done with filesystem objects, so can get stuck if a file is somehow left behind by an app… But on Windows, we use win32 global mutexes, where it’s the OS’s job to take care of that kind of thing, so I really don’t see anything we could be doing wrong. Certainly you can make things more reliable by making sure you always delete your InterProcessLock objects on shutdown and let them clean up, but if the process is killed, it’s the OS that should sort this out.

Thanks for your feedback, I’ll explicitly delete those instead of relying on static de-initialization and hope for the best, although for what I see those handlers should be released by Windows when the process dies. I’ll get back to you in case I find out anything you may be interested in :wink: