kdevelop exitting on its own - GOTCHA!

Milian Wolff mail at milianw.de
Sat Nov 15 20:23:44 GMT 2014


On Friday 14 November 2014 22:15:58 René J.V. Bertin wrote:
> On Friday November 14 2014 20:09:09 Kevin Funk wrote:
> >Ah, the joy of refcounting...
> 
> Yep...
> 
> >First of all:
> >- I've never seen this issue on Linux, so it must be OSX specific
> 
> You've never seen this issue on my machines either, so it must be in my
> imagination, right? :)

Huh what?

> Seriously, it happens on Linux too. Less often maybe, but that's probably
> because I rarely use KDevelop on Linux.
> 
> How many "sessions" do you have with multiple projects in them?

Tons. Actually I only have one session with just one project. all others have 
many projects in them, up to ~10 or more.

> >- We don't call KGlobal::deref explicitly afaics
> 
> I haven't indeed found it in git/master, I haven't yet gotten around to
> checking in the 1.7/4.7 branches.

I don't see it in those branches either.

> >really. *Any* loaded KDE library can cause this, since KGlobal is, well,
> >global, and everything can modify it.
> 
> Yes. For reference :) : ref() and deref() simply increase and decrease a
> static variable and don't provide a means to do meaningful debugging other
> than calling KBackTrace.

As Kevin mentioned, you'll have to use debugger scripting or similar to figure 
out whats going on here.

> What's the weirdest thing is that this doesn't occur systematically.
> Sessions will open fine most of the time, and then all of a sudden they ...
> quit. Relaunch the session, and most likely it'll behave correctly. Almost
> makes me wonder if we're looking at the effect of a missing mutex in ref()
> and deref(); at the very least I think they should use the equivalent of
> _InterlockedIncrement() and _InterlockedDecrement(), don't you think?

Indeed, s_refCount being a plain int sounds troublesome. You could either:

a) add an assertion in there that its only ever being called form the main 
thread:

    Q_ASSERT(QThread::currentThread() == qApp->thread())

Then look at which job is triggering this. Maybe on mac the timing is a bit 
different and then we sometimes see the race.

b) make it a QAtomicInt<int>

This should be the "fix" if we decide that this should be threadsafe.

> >Follow-up question: Is that the only KDE app behaving like that?
> 
> Yes. Or should I say, the only application it becomes apparent in. And yet I
> use Kontact and KMail, which have liberal use of KJob too ...

Bye
-- 
Milian Wolff
mail at milianw.de
http://milianw.de



More information about the KDevelop mailing list