Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Issues with stopping program execution #5

Open
sfranzen opened this issue Sep 20, 2015 · 3 comments
Open

Issues with stopping program execution #5

sfranzen opened this issue Sep 20, 2015 · 3 comments

Comments

@sfranzen
Copy link

I have incorporated the changes suggested @esoteric-programmer in #4 at my repo and started a port to Qt5 here. However, whether I compile the Qt4 (I have 4.8.6) or the Qt5 (5.5.0) version, I cannot seem to abort the execution of a program while in debugging mode.

Example output with qt4:

DP Right CC:  2 
DP Right CC:  2 
DP Right CC:  2 
abort! 

The program hangs at this point, with the Stop button depressed.

With qt5, the program crashes instead of hanging:

DP Right CC:  2
DP Right CC:  2
abort!
stop!
QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
Segmentation fault (core dumped)

I haven't looked at the source code too extensively so far, any idea where the error lies?

@esoteric-programmer
Copy link
Contributor

I cannot reproduce the crash (Qt 5.2.1 on Ubuntu 14.04 for x86).

Btw, I haven't looked at the code for execution/debugging yet. However, if I could reproduce your problem, I'd take a look.

@sfranzen
Copy link
Author

After getting the qt4 application to hang and terminating it, I get the following backtrace from thread 1:

Thread 1 (Thread 0x7ffff7faa780 (LWP 16284)):
#0  0x0000003d93afceb9 in syscall () at /lib64/libc.so.6
#1  0x0000003da36793b2 in QMutexPrivate::wait(int) () at /lib64/libQtCore.so.4
#2  0x0000003da3675675 in QMutex::lockInternal() () at /lib64/libQtCore.so.4
#3  0x00000000004393f6 in QMutex::lockInline() (this=0xa2e778) at /usr/include/QtCore/qmutex.h:198
#4  0x0000000000439325 in QMutexLocker::QMutexLocker(QMutex*) (this=0x7fffffffd1a0, m=0xa2e778) at /usr/include/QtCore/qmutex.h:109
#5  0x00000000004381a9 in RunController::abort() (this=0xa2e720) at /home/sigma/src/PietCreator/RunController.cpp:128
        locker = {val = 24}
#6  0x000000000042832a in MainWindow::slotStopController() (this=0x7fffffffe180) at /home/sigma/src/PietCreator/MainWindow.cpp:633
#7  0x0000000000428648 in MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=0x7fffffffe180, _c=QMetaObject::InvokeMetaMethod, _id=29, _a=0x7fffffffd2e0) at /home/sigma/src/PietCreator/build/MainWindow.moc:124
        _t = 0x7fffffffe180
#8  0x0000003da379e0c0 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () at /lib64/libQtCore.so.4
#9  0x00000000004288c9 in MainWindow::debugStop() (this=0x7fffffffe180) at /home/sigma/src/PietCreator/build/MainWindow.moc:200

There is more of course, but this is what happens after the debugStop signal is emitted. Pietcreator has hung on the QMutexLocker creation in the abort() method, stop() is never called. Unfortunately, I'm not well versed in thread programming; what is wrong here?

@esoteric-programmer
Copy link
Contributor

QMutex RunController::mMutex may be locked before abort() gets called. The problem seems to be a deadlock. However, at first view, I cannot find a missing unlock...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants