Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-32821

Segfault when a Qt Quick Controls Menu triggers a C++ slot that launches a modal QDialog

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.2.0
    • 5.1.0
    • None
    • Reproduced on 3 variants of Qt 5.1 from the Online installer:
      * Win 7 32-bit, "msvc2010 32-bit"
      * Win 8 64-bit, "msvc2012 64-bit OpenGL"
      * Win 8 64-bit, "MinGW 4.8 (32 bit)"

    Description

      Details
      The attached example contains:

      • A minimal Qt Quick Rectangle
        • Its MouseArea pops up a Qt Quick Controls Menu
        • It emits a signal when the menu is clicked
      • A minimal MainWindow from Qt Designer
        • Nothing added in Designer
        • Its central widget is a QQuickView containing the Rectangle
        • Its only function is to launch a QFileDialog in response the the Rectangle's signal

      Clicking the menu causes a segfault. If the signal was emitted in MouseEvent::onClicked instead of Menu::onTriggered, the dialog launches without crashing.

      In my full project, I have several QML signals from different menus, connected to different C++ slots. Every slot that launches a dialog (QFileDialog or custom QDialog-derived ones) exhibits this bug

      In my full project, the program crashes the very first time a menu is clicked. With this minimal example, it's harder to cause a crash (thus some repetitions may be required to reproduce it, as shown below)

      Steps to reproduce

      1. Compile + run the attached code in a debugger
      2. Click on the dark gray surface to open the menu, and select "Load Project"
      3. If it hasn't crashed yet, click "Cancel", maximize the window, and repeat step #2
      4. If it hasn't crashed yet, click "Cancel", un-maximize the window, and repeat step #2
      5. If it hasn't crashed yet, repeat steps #3 and #4 – it should crash within 5 iterations

      Workaround
      Explicitly set Qt::QueuedConnection for every connection that launches dialogs.

      Stack trace from MinGW build

      0	QSharedDataPointer<QWindowsWindowCursorData>::QSharedDataPointer	qshareddata.h	90	0x629053bc	
      1	QWindowsWindowCursor::QWindowsWindowCursor	qwindowscursor.cpp	504	0x62865bd7	
      2	QWindowsWindow::cursor	qwindowswindow.h	239	0x62918efc	
      3	applyNewCursor	qwindowswindow.cpp	1815	0x62847b3c	
      4	QWindowsWindow::setCursor	qwindowswindow.cpp	1825	0x62847bc6	
      5	QWindowsCursor::changeCursor	qwindowscursor.cpp	432	0x6286597e	
      6	QWindowPrivate::applyCursor	qwindow.cpp	2269	0x17fb27e2	
      7	QWindowPrivate::setCursor	qwindow.cpp	2255	0x17fb271d	
      8	QWindow::setCursor	qwindow.cpp	2214	0x17fb25a2	
      9	applyCursor	qwidget_qpa.cpp	1013	0x9822dc3	
      10	qt_qpa_set_cursor	qwidget_qpa.cpp	1051	0x9823001	
      11	QWidgetPrivate::setCursor_sys	qwidget_qpa.cpp	332	0x98208a3	
      12	QWidget::setCursor	qwidget.cpp	4599	0x9804af3	
      13	QSizeGrip::moveEvent	qsizegrip.cpp	445	0x9955942	
      14	QWidget::event	qwidget.cpp	8033	0x980d9fb	
      15	QSizeGrip::event	qsizegrip.cpp	503	0x9955b23	
      16	QApplicationPrivate::notify_helper	qapplication.cpp	3455	0x97ddaf1	
      17	QApplication::notify	qapplication.cpp	3420	0x97dd978	
      18	QCoreApplication::notifyInternal	qcoreapplication.cpp	871	0x6b90a8d6	
      19	QCoreApplication::sendEvent	qcoreapplication.h	232	0x9b155d1	
      20	QWidgetPrivate::sendPendingMoveAndResizeEvents	qwidget.cpp	6993	0x980b454	
      21	QWidgetPrivate::show_helper	qwidget.cpp	7050	0x980b73a	
      22	QWidgetPrivate::show_recursive	qwidget.cpp	6980	0x980b366	
      23	QWidgetPrivate::showChildren	qwidget.cpp	7388	0x980c4b8	
      24	QWidgetPrivate::show_helper	qwidget.cpp	7056	0x980b76a	
      25	QWidget::setVisible	qwidget.cpp	7307	0x980c08f	
      26	QDialog::setVisible	qdialog.cpp	711	0x99b51d5	
      27	QFileDialog::setVisible	qfiledialog.cpp	813	0x99b9fb7	
      28	QWidget::show	qwidget.cpp	6957	0x980b28f	
      29	QDialog::exec	qdialog.cpp	520	0x99b48ca	
      30	QFileDialog::getOpenFileName	qfiledialog.cpp	1792	0x99bc6e4	
      31	MainWindow::parseProject	mainwindow.cpp	22	0x4018fe	
      32	MainWindow::qt_static_metacall	moc_mainwindow.cpp	67	0x4019d1	
      33	QMetaObject::activate	qobject.cpp	3479	0x6b934cd0	
      34	QQmlVMEMetaObject::activate	qqmlvmemetaobject.cpp	1350	0xa046bf	
      35	QQmlVMEMetaObject::metaCall	qqmlvmemetaobject.cpp	907	0xa02ba2	
      36	QAbstractDynamicMetaObject::metaCall	qobject_p.h	413	0xb6506b	
      37	QMetaObject::metacall	qmetaobject.cpp	305	0x6b90f33a	
      38	CallMethod	qv8qobjectwrapper.cpp	1605	0xad17ab	
      39	CallPrecise	qv8qobjectwrapper.cpp	1839	0xad21aa	
      40	QV8QObjectWrapper::Invoke	qv8qobjectwrapper.cpp	2053	0xad2f27	
      41	v8::internal::HandleApiCallHelper<false>	builtins.cc	1164	0x10e8c175	
      42	v8::internal::Builtin_Impl_HandleApiCall	builtins.cc	1182	0x10e86def	
      43	v8::internal::Builtin_HandleApiCall	builtins.cc	1181	0x10e86dce	
      44	??			0x2210a236	
      45	??			0x22128e84	
      46	??			0x2215976b	
      47	??			0x2210fef9	
      48	??			0x2210a0aa	
      49	v8::internal::Invoke	execution.cc	125	0x10eae66e	
      50	v8::internal::Execution::Call	execution.cc	201	0x10eae9d0	
      51	v8::internal::Execution::Call	execution.cc	168	0x10eae822	
      52	v8::Function::Call	api.cc	3788	0x10e64389	
      53	QQmlJavaScriptExpression::evaluate	qqmljavascriptexpression.cpp	180	0xa7c422	
      54	QQmlJavaScriptExpression::evaluate	qqmljavascriptexpression.cpp	127	0xa7c15d	
      55	QQmlBoundSignalExpression::evaluate	qqmlboundsignal.cpp	223	0xa3b73c	
      56	QQmlBoundSignal_callback	qqmlboundsignal.cpp	384	0xa3c011	
      57	QQmlNotifier::emitNotify	qqmlnotifier.cpp	83	0xa6928f	
      58	QQmlData::signalEmitted	qqmlengine.cpp	658	0xa05656	
      59	QMetaObject::activate	qobject.cpp	3372	0x6b9347e1	
      60	QMetaObject::activate	qobject.cpp	3354	0x6b934672	
      61	QQuickMenuItem::triggered	moc_qquickmenuitem_p.cpp	803	0x6678992a	
      62	QQuickMenuItem::qt_static_metacall	moc_qquickmenuitem_p.cpp	661	0x667893d9	
      63	QMetaObject::activate	qobject.cpp	3479	0x6b934cd0	
      64	QMetaObject::activate	qobject.cpp	3354	0x6b934672	
      65	QQuickAction::triggered	moc_qquickaction_p.cpp	330	0x66787742	
      66	QQuickAction::trigger	qquickaction.cpp	390	0x6678250c	
      67	QQuickMenuItem::trigger	qquickmenuitem.cpp	607	0x66785e59	
      68	QQuickMenuItem::qt_static_metacall	moc_qquickmenuitem_p.cpp	668	0x6678944a	
      69	QQuickMenuItem::qt_metacall	moc_qquickmenuitem_p.cpp	749	0x667896c6	
      70	QMetaObject::metacall	qmetaobject.cpp	307	0x6b90f362	
      71	CallMethod	qv8qobjectwrapper.cpp	1605	0xad17ab	
      72	CallPrecise	qv8qobjectwrapper.cpp	1839	0xad21aa	
      73	QV8QObjectWrapper::Invoke	qv8qobjectwrapper.cpp	2053	0xad2f27	
      74	v8::internal::HandleApiCallHelper<false>	builtins.cc	1164	0x10e8c175	
      75	v8::internal::Builtin_Impl_HandleApiCall	builtins.cc	1182	0x10e86def	
      76	v8::internal::Builtin_HandleApiCall	builtins.cc	1181	0x10e86dce	
      77	??			0x2210a236	
      78	??			0x22128e84	
      79	??			0x22159117	
      80	??			0x22158eeb	
      81	??			0x2210fef9	
      82	??			0x2210a0aa	
      83	v8::internal::Invoke	execution.cc	125	0x10eae66e	
      84	v8::internal::Execution::Call	execution.cc	201	0x10eae9d0	
      85	v8::internal::Execution::Call	execution.cc	168	0x10eae822	
      86	v8::Function::Call	api.cc	3788	0x10e64389	
      87	QQmlJavaScriptExpression::evaluate	qqmljavascriptexpression.cpp	180	0xa7c422	
      88	QQmlJavaScriptExpression::evaluate	qqmljavascriptexpression.cpp	127	0xa7c15d	
      89	QQmlBoundSignalExpression::evaluate	qqmlboundsignal.cpp	223	0xa3b73c	
      90	QQmlBoundSignal_callback	qqmlboundsignal.cpp	384	0xa3c011	
      91	QQmlNotifier::emitNotify	qqmlnotifier.cpp	83	0xa6928f	
      92	QQmlData::signalEmitted	qqmlengine.cpp	658	0xa05656	
      93	QMetaObject::activate	qobject.cpp	3372	0x6b9347e1	
      94	QMetaObject::activate	qobject.cpp	3354	0x6b934672	
      95	QQuickMouseArea::released	moc_qquickmousearea_p.cpp	846	0x4501e1b	
      96	QQuickMouseArea::setPressed	qquickmousearea.cpp	1228	0x44738ad	
      97	QQuickMouseArea::mouseReleaseEvent	qquickmousearea.cpp	850	0x4472326	
      98	QQuickItemPrivate::deliverMouseEvent	qquickitem.cpp	4471	0x442d867	
      99	QQuickWindow::sendEvent	qquickwindow.cpp	2160	0x443d5a6	
      100	QQuickWindowPrivate::deliverMouseEvent	qquickwindow.cpp	1310	0x443a07a	
      101	QQuickWindow::mouseReleaseEvent	qquickwindow.cpp	1343	0x443a165	
      102	QQuickMenuPopupWindow::mouseReleaseEvent	qquickmenupopupwindow.cpp	208	0x66786c73	
      103	QWindow::event	qwindow.cpp	1842	0x17fb1cf5	
      104	QQuickWindow::event	qquickwindow.cpp	1211	0x4439a1a	
      105	QApplicationPrivate::notify_helper	qapplication.cpp	3455	0x97ddaf1	
      106	QApplication::notify	qapplication.cpp	2876	0x97db5b4	
      107	QCoreApplication::notifyInternal	qcoreapplication.cpp	871	0x6b90a8d6	
      108	QCoreApplication::sendSpontaneousEvent	qcoreapplication.h	235	0x18239305	
      109	QGuiApplicationPrivate::processMouseEvent	qguiapplication.cpp	1439	0x17faa447	
      110	QGuiApplicationPrivate::processWindowSystemEvent	qguiapplication.cpp	1262	0x17fa9c2d	
      111	QWindowSystemInterface::sendWindowSystemEventsImplementation	qwindowsysteminterface.cpp	581	0x17fa0760	
      112	QWindowSystemInterface::sendWindowSystemEvents	qwindowsysteminterface.cpp	561	0x17fa06ed	
      113	QWindowsGuiEventDispatcher::sendPostedEvents	qwindowsguieventdispatcher.cpp	86	0x6285ca79	
      114	qt_internal_proc	qeventdispatcher_win.cpp	429	0x6b9502fc	
      115	USER32!DestroyCaret	C:\WINDOWS\SysWOW64\user32.dll		0x755077d8	
      116	??			0x1806be	
      117	??			0x401	
      118	??				
      
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              smd Jan Arve
              jksh Sze Howe Koh
              Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes