Project

General

Profile

wtwithqt example (with enabled Qt eventloop) crashes

Added by Alexey K over 12 years ago

Hi!

Wtwithqt example with enabled Qt eventloop crashes (sooner or later - but usually sooner) when refreshed frequently (hold F5 in browser). Without eventloop everything works fine.

output looks something like:

[2012-May-18 16:44:16.729635] 6733 - [info] "WebRequest: took 1.257ms"
[2012-May-18 16:44:17.011841] 6733 - [info] "Wt: session created (#sessions = 2)"
[2012-May-18 16:44:17.012268] 6733 [/ 82XUwYv13c8nI7Jy] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111108 Iceweasel/3.5.16 (like Firefox/3.5.16)"
127.0.0.1 - - [2012-May-18 16:44:17.014115] "GET / HTTP/1.1" 200 1846
[2012-May-18 16:44:17.014200] 6733 - [info] "WebRequest: took 2.564ms"
127.0.0.1 - - [2012-May-18 16:44:17.021542] "POST /?wtd=715ZwHNOGaOyJlQT HTTP/1.1" 200 58
QThread: Destroyed while thread is still running
QMutex: mutex destroy failure: Device or resource busy
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
  what():  boost::lock_error

Error seems to happen on session destruction when trying to get boost::mutex::scoped_lock

What may cause the problem?

PS looks like similar issue already happened before:

http://redmine.webtoolkit.eu/issues/1034


Replies (5)

RE: wtwithqt example (with enabled Qt eventloop) crashes - Added by Jake Petroules over 12 years ago

I can also confirm that this problem occurs in the latest Git version of Wt.

RE: wtwithqt example (with enabled Qt eventloop) crashes - Added by Alexey K over 12 years ago

Hi again!

According to debug output listed above (QThread: Destroyed while thread is still running), Qthread is not always finished when delete is called.

A simple call to QThread::wait() in WQApplication::notify() before deleting a thread solves the problem... for now :)

void WQApplication::notify(const WEvent& e)
{
  if (!thread_) {
    thread_ = new DispatchThread(this, withEventLoop_);
    thread_->start();
    thread_->waitDone();
  }

  thread_->notify(e);

  if (finalized_) {
//      if (thread_->isRunning())
//          qFatal("thread still running!");
    thread_->wait();
    delete thread_;
    thread_ = 0;
  }
}

RE: wtwithqt example (with enabled Qt eventloop) crashes - Added by Koen Deforche over 12 years ago

Hey,

That sounds like a plausible problem and fix. I'ld appreciate to hear if that eliminates the problem entirely ?

Regards,

koen

RE: wtwithqt example (with enabled Qt eventloop) crashes - Added by Jake Petroules over 12 years ago

I elected to drop the Qt event loop integration in my project due to this issue (I originally needed it in order to use QtNetwork for some Amazon S3 API work) and used cURL instead (which has a natively synchronous API), rather than trying to use Qt's async API in a sync way. If I have time later I'll go back a few Git revisions and see if this does indeed appear to fix the problem, and will post my results.

RE: wtwithqt example (with enabled Qt eventloop) crashes - Added by Jake Petroules over 12 years ago

Koen, I did some testing and it appears that this solution (6f2cad2) resolves the problem.

    (1-5/5)