PDA

View Full Version : Mysterious crash on Mac when QDialog::exec() returns



olidem
12th January 2012, 21:23
Hi,
I am getting a strange error here on Mac OS X Lion, with Qt 4.8.0.

PLEASE NOTE THAT MY APP WORKS FINE ON WINDOWS, WITH Qt 4.5.2 !!!!



class MyDiag : public QDialog
{
....
public slots:
void reject(){
//do sth
QDialog::reject();
}
};

// in my code
MyDiag d(qApp->activeWindow());
d.exec();


Why does this code crash in the line where I call the QDialog::reject() ???
On Windows this runs abloutely fine.
Perhaps it is related to the new version of Qt?

Thanks for your help in advance....

wysota
12th January 2012, 21:25
Does your application do anything while the dialog is open?

olidem
12th January 2012, 21:41
yes, it does a lot :)
In particular, it execs other dialogs, or, shows other from QWidget derived classes.

wysota
12th January 2012, 21:50
Could it be that while this dialog is open something else causes something that might want to open the same dialog again?

olidem
12th January 2012, 22:14
No.
Would this be a problem?
I mean, I create a new instance of MyDiag and exec it. There should not be a problem anyway, right?

Moreover, I can't figure one single dialog or widget out that causes the crash,
now I found another scenario where anothr widget crashes as soon as it is closed.

What could I do wrong, such that the qt-window-system gets into trouble?
could an invalid signal-slot-connection have long-run-effects?


Here's a backtrace of such a Crash:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000011f
0x00826712 in qt_post_window_change_event ()
(gdb) bt
#0 0x00826712 in qt_post_window_change_event ()
#1 0x0082686a in qt_event_request_window_change ()
#2 0x00832f1f in QWidgetPrivate::hide_sys ()
#3 0x008e5185 in QWidgetPrivate::hide_helper ()
#4 0x008e46d5 in QWidget::setVisible ()
#5 0x00d13808 in QDialog::setVisible ()
#6 0x00d14320 in QDialog::done ()
#7 0x00d12860 in QDialog::reject ()
#8 0x0003fad3 in CustomerDetailDialog::reject (this=0xbfffe758) at CustomerDetailDialog.cpp:194
#9 0x000ea92d in CustomerDetailDialog::qt_static_metacall (_o=0xbfffe758, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0xbfffd94c) at moc_CustomerDetailDialog.cpp:64
#10 0x014df4d1 in QMetaObject::activate ()
#11 0x00ec1c2f in QAbstractButton::clicked ()
#12 0x00c180de in QAbstractButtonPrivate::emitClicked ()
#13 0x00c18dab in QAbstractButtonPrivate::click ()
#14 0x00c18f67 in QAbstractButton::mouseReleaseEvent ()
#15 0x008e2fdb in QWidget::event ()
#16 0x00c180a4 in QAbstractButton::event ()
#17 0x00cae4ac in QPushButton::event ()
#18 0x00892eba in QApplicationPrivate::notify_helper ()
#19 0x00893917 in QApplication::notify ()
#20 0x014ca0d6 in QCoreApplication::notifyInternal ()
#21 0x0089bae4 in QApplicationPrivate::sendMouseEvent ()
#22 0x008470c6 in qt_mac_handleMouseEvent ()
#23 0x008397db in -[QCocoaView mouseUp:] ()
#24 0x9ab738af in -[NSWindow sendEvent:] ()
#25 0x0083e277 in -[QCocoaWindow sendEvent:] ()
#26 0x9ab0b6ff in -[NSApplication sendEvent:] ()
#27 0x00841d1b in -[QNSApplication sendEvent:] ()
#28 0x9ad75b83 in -[NSApplication _modalSession:sendEvent:] ()
#29 0x9ad7574d in -[NSApplication _realDoModalLoop:peek:] ()
#30 0x9ad709e1 in -[NSApplication _doModalLoop:peek:] ()
#31 0x9ad6c9bc in -[NSApplication runModalSession:] ()
#32 0x0084b751 in QEventDispatcherMac::processEvents ()
#33 0x014c75b0 in QEventLoop::exec ()
#34 0x00d144d4 in QDialog::exec ()
// <=======this is where I call MyDiag::exec() =======================
#35 0x000517a9 in CustomerLibrary::addCustomer (this=0xbffff7a0, gotoStyler=true) at CustomerLibrary.cpp:212
#36 0x00051b95 in CustomerLibrary::addNewCustomerAndGotoHairstyler (this=0xbffff7a0) at CustomerLibrary.cpp:237
#37 0x000ebc64 in CustomerLibrary::qt_static_metacall (_o=0xbffff7a0, _c=QMetaObject::InvokeMetaMethod, _id=4, _a=0xbfffe9bc) at moc_CustomerLibrary.cpp:68
#38 0x014df4d1 in QMetaObject::activate ()
#39 0x00ec1c2f in QAbstractButton::clicked ()
#40 0x00c180de in QAbstractButtonPrivate::emitClicked ()
#41 0x00c18dab in QAbstractButtonPrivate::click ()
#42 0x00c18f67 in QAbstractButton::mouseReleaseEvent ()
#43 0x008e2fdb in QWidget::event ()
#44 0x00c180a4 in QAbstractButton::event ()
#45 0x00cae4ac in QPushButton::event ()
#46 0x00892eba in QApplicationPrivate::notify_helper ()
#47 0x00893917 in QApplication::notify ()
#48 0x014ca0d6 in QCoreApplication::notifyInternal ()
#49 0x0089bae4 in QApplicationPrivate::sendMouseEvent ()
#50 0x008470c6 in qt_mac_handleMouseEvent ()
#51 0x008397db in -[QCocoaView mouseUp:] ()
#52 0x9ab738af in -[NSWindow sendEvent:] ()
#53 0x0083e277 in -[QCocoaWindow sendEvent:] ()
#54 0x9ab0b6ff in -[NSApplication sendEvent:] ()
#55 0x00841d1b in -[QNSApplication sendEvent:] ()
#56 0x9aa9cc82 in -[NSApplication run] ()
#57 0x0084b87a in QEventDispatcherMac::processEvents ()
#58 0x014c75b0 in QEventLoop::exec ()
#59 0x014ca857 in QCoreApplication::exec ()
#60 0x000ce038 in main (argc=1, argv=0xbffffc38) at main.cpp:120

wysota
12th January 2012, 22:21
Would this be a problem?
Yes, it's a common crashing pattern :)


I mean, I create a new instance of MyDiag and exec it. There should not be a problem anyway, right?
If something else doesn't try to exec the same instance then no.


Moreover, I can't figure one single dialog or widget out that causes the crash,
now I found another scenario where anothr widget crashes as soon as it is closed.

What could I do wrong, such that the qt-window-system gets into trouble?
could an invalid signal-slot-connection have long-run-effects?

Run your app under a debugger and print a backtrace upon a crash.

olidem
12th January 2012, 22:28
see my post above, i edited it

Uhhh,
I just found that...
I AM using QGLWidget....
https://bugreports.qt.nokia.com/browse/QTBUG-20652

wysota
12th January 2012, 22:29
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000011f
You have a null pointer somewhere. Looks like an event is sent to some widget that doesn't exist anymore. You should be looking in the CustomerDetailDialog.

olidem
14th January 2012, 17:32
Still, I have not found a solution.
One question about the bug I found (see last post):

Can I expect such a known bug to be fixed in the foreseeable future?

If not, then I would maybe have to revoke my support of Mac OS or go back to an older verison of Qt.

wysota
14th January 2012, 17:46
Can I expect such a known bug to be fixed in the foreseeable future?
You can expect anything you want although I wouldn't bet on it getting fixed soon.


If not, then I would maybe have to revoke my support of Mac OS or go back to an older verison of Qt.
Or you can work around the problem. Where do you change the parent of your GL widget?