Application crash on QEventloop::exec() on MacOs
-
Please post the full stack trace going all down to
main()
and do it as text, not as a screenshot. More to the matter you can get such a trace when you have a posted event on an object which was deleted before the event's been processed. Check if you're not deleting aQObject
(aQWidget
in this case) directly withdelete
while it has still pending events (you can useQObject::deleteLater
instead) and make sure you do not usedelete
in a slot. -
@kshegunov Thanks for the reply there is no delete in any slot.
This is the whole stack trace.1 __pthread_kill (x86_64) /usr/lib/system/libsystem_kernel.dylib 0x7fff796a92c6
2 pthread_kill (x86_64) /usr/lib/system/libsystem_pthread.dylib 0x7fff79764bf1
3 abort (x86_64) /usr/lib/system/libsystem_c.dylib 0x7fff796136a6
4 __assert_rtn (x86_64) /usr/lib/system/libsystem_c.dylib 0x7fff795dc20d
5 hb_font_set_user_data (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x1014d8116
6 QTextEngine::shapeTextWithHarfbuzzNG(QScriptItem const&, unsigned short const *, int, QFontEngine *, QVector<unsigned int> const&, bool, bool) const (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x10121d71c
7 QTextEngine::shapeText(int) const (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x10121c0ca
8 QTextLine::layout_helper(int) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x1012345a2
9 qt_format_text(QFont const&, QRectF const&, int, QTextOption const *, QString const&, QRectF *, int, int *, int, QPainter *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x101393b25
10 QPainter::drawText(QRect const&, int, QString const&, QRect *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x101392dfc
11 QStyle::drawItemText(QPainter *, QRect const&, int, QPalette const&, bool, QString const&, QPalette::ColorRole) const (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bf5238
12 QLabel::paintEvent(QPaintEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100cb8fdc
13 QWidget::event(QEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bc0738
14 QFrame::event(QEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100c6822d
15 QApplicationPrivate::notify_helper(QObject *, QEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100b8477d
16 QApplication::notify(QObject *, QEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100b85b82
17 QCoreApplication::notifyInternal2(QObject *, QEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/QtCore 0x1019a1574
18 QWidgetPrivate::drawWidget(QPaintDevice *, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb93f1
19 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb9ad0
20 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
21 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
22 QWidgetPrivate::drawWidget(QPaintDevice *, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb9523
23 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb9ad0
24 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
25 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
26 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
27 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
28 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
29 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
30 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
31 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
32 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
33 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
34 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb996d
35 QWidgetPrivate::drawWidget(QPaintDevice *, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb9523
36 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *, QList<QObject *> const&, int, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb9ad0
37 QWidgetPrivate::drawWidget(QPaintDevice *, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb9523
38 QWidgetPrivate::render(QPaintDevice *, QPoint const&, QRegion const&, QFlagsQWidget::RenderFlag) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb7f39
39 QWidget::render(QPainter *, QPoint const&, QRegion const&, QFlagsQWidget::RenderFlag) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb7203
40 QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem, QPoint *, QGraphicsEffect::PixmapPadMode) const (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bba02a
41 QGraphicsEffectSource::pixmap(Qt::CoordinateSystem, QPoint *, QGraphicsEffect::PixmapPadMode) const (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100f1d472
42 QGraphicsDropShadowEffect::draw(QPainter *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100f1f29c
43 QWidgetPrivate::drawWidget(QPaintDevice *, QRegion const&, QPoint const&, int, QPainter *, QWidgetBackingStore *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bb8e37
44 QWidgetBackingStore::doSync() (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100b92194
45 QWidgetBackingStore::sync(QWidget *, QRegion const&) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100b90b2b
46 QWidgetWindow::handleExposeEvent(QExposeEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100be15d4
47 QWidgetWindow::event(QEvent *) (x86_64) /Users/maitreyi/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100bde94b
48 QApplicationPrivate::notify_helper(QObject *, QEvent *) (x86_64) /Users/maitreyi/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100b8477d
49 QApplication::notify(QObject *, QEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets 0x100b85b82
50 QCoreApplication::notifyInternal2(QObject *, QEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/QtCore 0x1019a1574
51 QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x10114ce65
52 bool QWindowSystemInterfacePrivate::handleWindowSystemEventQWindowSystemInterface::SynchronousDelivery(QWindowSystemInterfacePrivate::WindowSystemEvent *) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x10112b0e3
53 void QWindowSystemInterface::handleExposeEventQWindowSystemInterface::SynchronousDelivery(QWindow *, QRegion const&) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/QtGui 0x101132072
54 QCocoaWindow::handleExposeEvent(QRegion const&) (x86_64) /Users/x/Qt/5.12.6/clang_64/plugins/platforms/libqcocoa.dylib 0x102ade00c
55 -[QNSView(Drawing) displayLayer:] (x86_64) /Users/x/Qt/5.12.6/clang_64/plugins/platforms/libqcocoa.dylib 0x102ae65de
56 -[CALayer display] (x86_64) /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore 0x7fff580708e1
57 _NSBackingLayerDisplay (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff4ad1074e
58 -[_NSViewBackingLayer display] (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff4acf4c4f
59 CA::Layer::display_if_needed(CA::Transaction *) (x86_64) /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore 0x7fff58070551
60 CA::Context::commit_transaction(CA::Transaction *) (x86_64) /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore 0x7fff5805e7c6
61 CA::Transaction::commit() (x86_64) /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore 0x7fff5805dea6
62 __65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff4aceb84d
63 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION (x86_64h) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7fff4d651688
64 __CFRunLoopDoObservers (x86_64h) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7fff4d6515bd
65 __CFRunLoopRun (x86_64h) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7fff4d5f3ce0
66 CFRunLoopRunSpecific (x86_64h) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7fff4d5f361e
67 RunCurrentEventLoopInMode (x86_64) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox 0x7fff4c8521ab
68 ReceiveNextEventCommon (x86_64) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox 0x7fff4c851ded
69 _BlockUntilNextEventMatchingListInModeWithFilter (x86_64) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox 0x7fff4c851c76
70 _DPSNextEvent (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff4abea77d
71 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff4abe946b
72 -[NSApplication run] (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff4abe3588
73 QCocoaEventDispatcher::processEvents(QFlagsQEventLoop::ProcessEventsFlag) (x86_64) /Users/x/Qt/5.12.6/clang_64/plugins/platforms/libqcocoa.dylib 0x102af5013
74 QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/QtCore 0x10199cb8f
75 Contact_API_Comm::get_pending_Requests(QString) contact_api_comm.cpp 748 0x10002cc1a
76 ShowContactList::User_withContacts(QJsonArray const&) showcontactlist.cpp 327 0x1000dbb05
77 Home::on_contactlistButton_clicked() home.cpp 163 0x10007cbb4
78 Home::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *) moc_home.cpp 119 0x10012d67d
79 Home::qt_metacall(QMetaObject::Call, int, void * *) moc_home.cpp 166 0x10012d8e5
80 QMetaObject::activate(QObject *, int, int, void * *) -
@Anj_San said in Application crash on QEventloop::exec() on MacOs:
This is the whole stack trace.
I am pretty certain it is not.
QMetaObject::activate(QObject *, int, int, void * *)
can't be the call stack's root. Is threading used in this application? Please show the implementation ofContact_API_Comm::get_pending_Requests
method. -
@kshegunov This is my implementation:-
QJsonArray Contact_API_Comm::get_pending_Requests(QString token, QString url)
{QUrl serviceUrl = QUrl(url); QNetworkRequest request(serviceUrl); request.setRawHeader("Authorization",token.toUtf8()); Networkmanager->get(request); QObject::connect(Networkmanager, SIGNAL(finished(QNetworkReply*)), this,SLOT(serviceContactRequestFinished(QNetworkReply*))); loop.exec(); disconnect(Networkmanager, SIGNAL(finished(QNetworkReply*)), this,SLOT(serviceContactRequestFinished(QNetworkReply*))); return user_contact;
}
void Contact_API_Comm::serviceContactRequestFinished(QNetworkReply *reply)
{QVariant Status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); QByteArray buffer = reply->readAll(); QJsonDocument jsonDoc(QJsonDocument::fromJson(buffer)); qDebug() << jsonDoc; QJsonObject jsonReply = jsonDoc.object(); if(Status_code.toInt() == 200) { if(jsonReply.contains("userlist")) { user_contact = jsonReply["userlist"].toArray(); } if(jsonReply.contains("message")){ message = jsonReply["message"].toString(); } } else if(Status_code.toInt() == 422) { message = jsonReply["message"].toString(); qDebug()<<message; } else { message = "Could not connect at the moment"; } reply->deleteLater(); loop.exit(0);
}
-
Don't use local event loops, especially where when there's no pressing need to. You're spinning the global even loop and you have no idea what events are processed in the meantime. Here's a suggestion:
QJsonArray Contact_API_Comm::get_pending_Requests(QString token, QString url) { QNetworkRequest request(QUrl(url)); request.setRawHeader("Authorization", token.toUtf8()); QNetworkReply * reply = Networkmanager->get(request); QObject::connect(reply, &QNetworkReply::finished, this, std::bind(&Contact_API_Comm::serviceContactRequestFinished, this, reply)); QObject::connect(reply, &QNetworkReply::finished, reply, &QObject::deleteLater); } void Contact_API_Comm::serviceContactRequestFinished(QNetworkReply *reply) { QJsonArray result; // Read the json data into `result` emit contactReceived(result); //< This signal you declare yourself and connect something to it to process the data further }
-
@kshegunov I have tried this but now the app is crashing with this stack trace
1 objc_msgSend (x86_64h) /usr/lib/libobjc.A.dylib 0x7fff6051b6a9
2 (anonymous namespace)::AutoreleasePoolPage::pop(void *) (x86_64h) /usr/lib/libobjc.A.dylib 0x7fff6051e47c
3 _CFAutoreleasePoolPop (x86_64h) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7fff35d4fd4a
4 -[NSAutoreleasePool drain] (x86_64) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation 0x7fff37ffa792
5 -[NSApplication run] (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff3336c5f7
6 QCocoaEventDispatcher::processEvents(QFlagsQEventLoop::ProcessEventsFlag) (x86_64) /Users/x/Qt/5.12.6/clang_64/plugins/platforms/libqcocoa.dylib 0x1029fd013
7 QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/QtCore 0x1018b1b8f
8 QCoreApplication::exec() (x86_64) /Users/x/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/QtCore 0x1018b6b82
9 main (x86_64) /Users/x/build-Aact-Desktop_Qt_5_12_6_clang_64bit-Release/Aact.app/Contents/MacOS/Aact 0x100079e7b
10 start (x86_64) /usr/lib/system/libdyld.dylib 0x7fff61cf73d5 -
Hi,
What version of macOS are you running ?
-
You seem to have a lot of QEventLoop instances spread over your code, why so many ?
-
@Anj_San said in Application crash on QEventloop::exec() on MacOs:
Is using too many even loop instance is a wrong?
Yes. Use assynchronous nature of Qt like @kshegunov shown