Review Request 121134: make KGlobal reference counting threadsafe

René J.V. Bertin rjvbertin at gmail.com
Sun Nov 16 19:13:05 GMT 2014



> On Nov. 16, 2014, 8:05 p.m., Pino Toscano wrote:
> > kdecore/kernel/kglobal.cpp, lines 323-324
> > <https://git.reviewboard.kde.org/r/121134/diff/3/?file=328834#file328834line323>
> >
> >     QAtomicInt is not a POD, so it is not safe to be used this way. You rather need to use the semi-private QBasicAtomicInt, which is not a POD, like:
> >     
> >         static QBasicAtomicInt s_allowQuit = Q_BASIC_ATOMIC_INITIALIZER(0);
> >     
> >     The API should be the same.

Personal education: what does POD stand for in this context?


- René J.V.


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/121134/#review70463
-----------------------------------------------------------


On Nov. 16, 2014, 8:01 p.m., René J.V. Bertin wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/121134/
> -----------------------------------------------------------
> 
> (Updated Nov. 16, 2014, 8:01 p.m.)
> 
> 
> Review request for KDE Software on Mac OS X and kdelibs.
> 
> 
> Repository: kdelibs
> 
> 
> Description
> -------
> 
> I have been experiencing unexpected exits from KDevelop that were not due to any kind of error in the KDevelop code; it was as if someone told the application to exit normally. This happens mostly on OS X, but also sometimes on Linux.
> I finally traced this to `KGlobal::deref` reaching a zero reference count and invoking `QCoreApplication::quit` when called from one of KDevelop's KJob dtors. There does not appear to be a reference counting mismatch in the code, so the issue might be due to a race condition in KGlobal::ref/deref.
> 
> This patch introduces thread-safety to KGlobal's reference counting by turning the simple global `static int s_refCount` into a `static QAtomicInt s_refCount`. I consider this an important bug fix regardless of whether it corrects the issue I have with KDevelop.
> 
> 
> Diffs
> -----
> 
>   kdecore/kernel/kglobal.cpp cf003a4 
> 
> Diff: https://git.reviewboard.kde.org/r/121134/diff/
> 
> 
> Testing
> -------
> 
> On OS X 10.6.8 only for now.
> 
> NB: Qt itself uses the QAtomicInt's parent class (QBasicAtomicInt) for its own reference counter used for implicit sharing. This is thus well-tested code that is unlikely to introduce regressions to a core KDE feature.
> 
> 
> Thanks,
> 
> René J.V. Bertin
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20141116/ad83f6f1/attachment.htm>


More information about the kde-core-devel mailing list