[prev in list] [next in list] [prev in thread] [next in thread]
List: kdevelop-devel
Subject: Re: [KDevPlatform] bae38ce: Use pthread directly for the foreground
From: Aleix Pol <aleixpol () kde ! org>
Date: 2010-12-02 23:24:36
Message-ID: AANLkTikXUo0mz58rW2eKfrus1D2Dc0RZWC1NZmZSoheL () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
On Wed, Dec 1, 2010 at 6:04 PM, Milian Wolff <mail@milianw.de> wrote:
> Sorry David, but this is a no-go. Pthread is not cross-platform, and I
> still
> did not find a single reason for why this should be a QMutex bug. Why does
> that work for us in all other cases (and tons of other projects), but no
> here?
>
> Really, instead of putting work-around over work-around, we should dissect
> this problem and find the *real* reason.
>
> Doing guess-work won't help, and so far you only proposed that there
> *could*
> be a bug in QMutex, without
>
> a) explaining where the bug occurs
> b) reporting a bug to Nokia
>
> I'm heavily opposed to this, imo you should start to write unit tests and
> try
> to reproduce the deadlock before adding more workarounds.
>
> Bye
>
> David Nolden, 01.12.2010:
> > commit bae38ceb983f7c7b0b66ca475dbfa689ace8313e
> > branch master
> > Author: David Nolden <david.nolden.kde@art-master.de>
> > Date: Wed Dec 1 17:53:52 2010 +0100
> >
> > Use pthread directly for the foreground mutex, potentially trying to
> > workaround a problem in the QMutex implementation which leads to a rare
> > deadlock. BUG: 252659
> >
> > diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt
> > index 4fd1ec4..d832c85 100644
> > --- a/interfaces/CMakeLists.txt
> > +++ b/interfaces/CMakeLists.txt
> > @@ -49,7 +49,8 @@ target_link_libraries(kdevplatforminterfaces
> > ${KDE4_KTEXTEDITOR_LIBS}
> > ${KDE4_THREADWEAVER_LIBRARIES}
> > ${QT_QTDESIGNER_LIBRARY}
> > - ${KDE4_KROSSCORE_LIBS})
> > + ${KDE4_KROSSCORE_LIBS}
> > + rt)
> > target_link_libraries(kdevplatforminterfaces LINK_INTERFACE_LIBRARIES
> > ${KDE4_KPARTS_LIBS}
> > ${KDE4_KTEXTEDITOR_LIBS}
> > diff --git a/interfaces/foregroundlock.cpp
> b/interfaces/foregroundlock.cpp
> > index ada7db9..4e3a73d 100644
> > --- a/interfaces/foregroundlock.cpp
> > +++ b/interfaces/foregroundlock.cpp
> > @@ -24,8 +24,65 @@
> >
> > using namespace KDevelop;
> >
> > +#define USE_PTHREAD_MUTEX
> > +
> > +#ifdef USE_PTHREAD_MUTEX
> > +
> > +#include <pthread.h>
> > +#include <time.h>
> > +
> > +
> > +class SimplePThreadMutex {
> > +public:
> > + SimplePThreadMutex() {
> > + m_mutex = PTHREAD_MUTEX_INITIALIZER;
> > + int result = pthread_mutex_init(&m_mutex, 0);
> > + Q_ASSERT(result == 0);
> > + }
> > + ~SimplePThreadMutex() {
> > + pthread_mutex_destroy(&m_mutex);
> > + }
> > + void lock() {
> > + int result = pthread_mutex_lock(&m_mutex);
> > + Q_ASSERT(result == 0);
> > + }
> > + void unlock() {
> > + int result = pthread_mutex_unlock(&m_mutex);
> > + Q_ASSERT(result == 0);
> > + }
> > + bool tryLock(int interval) {
> > + if(interval == 0)
> > + {
> > + int result = pthread_mutex_trylock(&m_mutex);
> > + return result == 0;
> > + }else{
> > + timespec abs_time;
> > + clock_gettime(CLOCK_REALTIME, &abs_time);
> > + abs_time.tv_nsec += interval * 1000000;
> > + if(abs_time.tv_nsec >= 1000000000)
> > + {
> > + abs_time.tv_nsec -= 1000000000;
> > + abs_time.tv_sec += 1;
> > + }
> > +
> > + int result = pthread_mutex_timedlock(&m_mutex, &abs_time);
> > + return result == 0;
> > + }
> > + }
> > +
> > +private:
> > + pthread_mutex_t m_mutex;
> > +};
> > +
> > namespace {
> > +
> > +SimplePThreadMutex internalMutex;
> > +#else
> > +
> > +namespace {
> > +
> > QMutex internalMutex;
> > +#endif
> > QMutex tryLockMutex;
> > QMutex waitMutex;
> > QMutex finishMutex;
>
>
> --
> Milian Wolff
> mail@milianw.de
> http://milianw.de
>
> --
> KDevelop-devel mailing list
> KDevelop-devel@kdevelop.org
> https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
>
>
What happened with that one?
Aleix
[Attachment #5 (text/html)]
<div class="gmail_quote">On Wed, Dec 1, 2010 at 6:04 PM, Milian Wolff <span dir="ltr"><<a \
href="mailto:mail@milianw.de">mail@milianw.de</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> \
Sorry David, but this is a no-go. Pthread is not cross-platform, and I still<br> did not find a \
single reason for why this should be a QMutex bug. Why does<br> that work for us in all other \
cases (and tons of other projects), but no here?<br> <br>
Really, instead of putting work-around over work-around, we should dissect<br>
this problem and find the *real* reason.<br>
<br>
Doing guess-work won't help, and so far you only proposed that there *could*<br>
be a bug in QMutex, without<br>
<br>
a) explaining where the bug occurs<br>
b) reporting a bug to Nokia<br>
<br>
I'm heavily opposed to this, imo you should start to write unit tests and try<br>
to reproduce the deadlock before adding more workarounds.<br>
<br>
Bye<br>
<br>
David Nolden, 01.12.2010:<br>
> commit bae38ceb983f7c7b0b66ca475dbfa689ace8313e<br>
> branch master<br>
> Author: David Nolden <<a \
href="mailto:david.nolden.kde@art-master.de">david.nolden.kde@art-master.de</a>><br> > \
Date: Wed Dec 1 17:53:52 2010 +0100<br> ><br>
> Use pthread directly for the foreground mutex, potentially trying to<br>
> workaround a problem in the QMutex implementation which leads to a rare<br>
> deadlock. BUG: 252659<br>
><br>
> diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt<br>
> index 4fd1ec4..d832c85 100644<br>
> --- a/interfaces/CMakeLists.txt<br>
> +++ b/interfaces/CMakeLists.txt<br>
> @@ -49,7 +49,8 @@ target_link_libraries(kdevplatforminterfaces<br>
> ${KDE4_KTEXTEDITOR_LIBS}<br>
> ${KDE4_THREADWEAVER_LIBRARIES}<br>
> ${QT_QTDESIGNER_LIBRARY}<br>
> - ${KDE4_KROSSCORE_LIBS})<br>
> + ${KDE4_KROSSCORE_LIBS}<br>
> + rt)<br>
> target_link_libraries(kdevplatforminterfaces LINK_INTERFACE_LIBRARIES<br>
> ${KDE4_KPARTS_LIBS}<br>
> ${KDE4_KTEXTEDITOR_LIBS}<br>
> diff --git a/interfaces/foregroundlock.cpp b/interfaces/foregroundlock.cpp<br>
> index ada7db9..4e3a73d 100644<br>
> --- a/interfaces/foregroundlock.cpp<br>
> +++ b/interfaces/foregroundlock.cpp<br>
> @@ -24,8 +24,65 @@<br>
><br>
> using namespace KDevelop;<br>
><br>
> +#define USE_PTHREAD_MUTEX<br>
> +<br>
> +#ifdef USE_PTHREAD_MUTEX<br>
> +<br>
> +#include <pthread.h><br>
> +#include <time.h><br>
> +<br>
> +<br>
> +class SimplePThreadMutex {<br>
> +public:<br>
> + SimplePThreadMutex() {<br>
> + m_mutex = PTHREAD_MUTEX_INITIALIZER;<br>
> + int result = pthread_mutex_init(&m_mutex, 0);<br>
> + Q_ASSERT(result == 0);<br>
> + }<br>
> + ~SimplePThreadMutex() {<br>
> + pthread_mutex_destroy(&m_mutex);<br>
> + }<br>
> + void lock() {<br>
> + int result = pthread_mutex_lock(&m_mutex);<br>
> + Q_ASSERT(result == 0);<br>
> + }<br>
> + void unlock() {<br>
> + int result = pthread_mutex_unlock(&m_mutex);<br>
> + Q_ASSERT(result == 0);<br>
> + }<br>
> + bool tryLock(int interval) {<br>
> + if(interval == 0)<br>
> + {<br>
> + int result = pthread_mutex_trylock(&m_mutex);<br>
> + return result == 0;<br>
> + }else{<br>
> + timespec abs_time;<br>
> + clock_gettime(CLOCK_REALTIME, &abs_time);<br>
> + abs_time.tv_nsec += interval * 1000000;<br>
> + if(abs_time.tv_nsec >= 1000000000)<br>
> + {<br>
> + abs_time.tv_nsec -= 1000000000;<br>
> + abs_time.tv_sec += 1;<br>
> + }<br>
> +<br>
> + int result = pthread_mutex_timedlock(&m_mutex, &abs_time);<br>
> + return result == 0;<br>
> + }<br>
> + }<br>
> +<br>
> +private:<br>
> + pthread_mutex_t m_mutex;<br>
> +};<br>
> +<br>
> namespace {<br>
> +<br>
> +SimplePThreadMutex internalMutex;<br>
> +#else<br>
> +<br>
> +namespace {<br>
> +<br>
> QMutex internalMutex;<br>
> +#endif<br>
> QMutex tryLockMutex;<br>
> QMutex waitMutex;<br>
> QMutex finishMutex;<br>
<font color="#888888"><br>
<br>
--<br>
Milian Wolff<br>
<a href="mailto:mail@milianw.de">mail@milianw.de</a><br>
<a href="http://milianw.de" target="_blank">http://milianw.de</a><br>
</font><br>--<br>
KDevelop-devel mailing list<br>
<a href="mailto:KDevelop-devel@kdevelop.org">KDevelop-devel@kdevelop.org</a><br>
<a href="https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel" \
target="_blank">https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel</a><br> \
<br></blockquote></div><br><div>What happened with that \
one?</div><div><br></div><div>Aleix</div>
--
KDevelop-devel mailing list
KDevelop-devel@kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic