Summary: | hang/deadlock when enabling background parser | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Till Adam <adam> |
Component: | Language Support: CPP (old) | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | david.nolden.kde |
Priority: | NOR | ||
Version: | git master | ||
Target Milestone: | 4.2.0 | ||
Platform: | Compiled Sources | ||
OS: | macOS | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | handle tryLock returning false with the lock held |
Description
Till Adam
2010-12-11 12:55:02 UTC
*** This bug has been marked as a duplicate of bug 252659 *** Please use the debugger to print the "recursion" and "holderThread" parameters in foregroundlock.cpp. This maybe not a duplicate, but some mac-specific problem in the way ForegroundLock is integrated into KDevelop (maybe the event-processing is done differently there). Things seem to end up in a state where the internalMutex is held by some thread, but the holderThread is 0, as is recursion. I'm plastering things with a few more asserts, as this clearly means some assumptions are being violated somewhere along the way. Well, look at lockInternalMutex, unlockInternalMutex, and relockInternalMutex. Those should contain enough assertions to make sure what you told doesn't happen.. Maybe it _is_ the same problem as on linux after all. Try enabling the pthread mutex, by replacing the "#if defined(USE_PTHREAD_MUTEX) && defined(Q_OS_LINUX)" with "#if defined(USE_PTHREAD_MUTEX)" in foregroundlock.cpp. Apparently QMutex::tryLock behaves unexpectedly in that it can return false, indicating that the try timed out, yet the lock has actually been acquired. This is the only way that I can see getting into the scenario that debugging shows, where the holderThread is 0, but attempting to acquire the lock fails. I'm attaching a patch which seems to work around the issue successfully here. It also uses QAtomicInt and QAtomicPointer, for a little bit more safety. Created attachment 54485 [details]
handle tryLock returning false with the lock held
Ok. The workaround isn't safe, maybe it would be if it used something like QAtomic::testAndSet(..) instead of the if(holderThread == 0). Anyway that would kind-of mean we're implementing our own mutex, which we don't want to. If it's true that tryLock can return true even the the lock was successful, then this is a big fat Qt bug. The only feasible workaround is using another mutex implementation for now (maybe from boost::threading). Oh sorry, actually I was doing the test with the pthread mutex enabled. :-) The last message was supposed for bug 252659. *** This bug has been marked as a duplicate of bug 252659 *** Moving all the bugs from the CPP Parser. It was not well defined the difference between it and C++ Language Support and people kept reporting in both places indistinctively |