KDevelop::DUChainLock::lockForWrite: Tried to lock the duchain for writing, but it was already locked for reading here

Andreas Pakulat apaku at gmx.de
Tue Oct 7 20:19:46 UTC 2008


On 07.10.08 19:38:17, Peter Oberndorfer wrote:
> On Montag 06 Oktober 2008, Peter Oberndorfer wrote:
> > Hi,
> > i get the following error with current kdevplatform/kdevelop
> > KDevelop::DUChainLock::lockForWrite: Tried to lock the duchain for writing, 
> > but it was already locked for reading here
> > 
> > how to reproduce:
> > start kdevelop
> > open oketa project, open about.cpp
> > select OketaAboutData::OketaAboutData()
> > open DUChain viewer
> > double click the second Context: line
> > A message box comes up that says kgraphviewer or dotty is not available
> > (this messagebox is essential for the bug)
> > wait some time with the messagebox open until duchain cleanup is triggered by 
> > a timer.
> > -> assert
> > 
> > A patch for kdevplatform is attached, which seems to solve this problem for 
> > me.
> > 
> > What i do not fully understand is why there are 2
> > DUChainReadLocker readLock(DUChain::lock());
> > in DUChainModel::doubleClicked
> > and for the above KMessageBox only the inner one of them is released?
> > 
> > So wouldn't it be possible that the same error happens for
> > KMessageBox::error(0, i18n("Cannot create temporary file...
> > since the outer lock is still locked?
> > Do i misunderstand locking?
> > 
> To answer my own question, yes the same problem happens for the first KMessageBox.
> The attached patch should fix that one too.
> 
> Changelog:
> Always release the DUChain readLock before showing a KMessageBox.
> Otherwise a timer could fire while the KMessageBox is open and cause problems trying to enter a writeLock.
> Use only 1 DUChainReadLocker instance instead of 2.

Interesting, do you have more information about which timer might fire and
which component then tries to acquire a writeLock? I mean this kind of
thing might be scattered all over the codebase by now and we should better
try to find the places... In particular I've recently fixed something
similar in vcscommon plugin, which indirectly caused another event-loop to
run which apparently caused the timer to fire....

Andreas

-- 
You get along very well with everyone except animals and people.




More information about the KDevelop-devel mailing list