"WARN: QCoreApplication::postEvent: Unexpected null receiver" since 5.10.1



  • Dear Qt community,

    Since I updated from 5.10.0 to 5.10.1, I have a few of those warnings appearing when running my application.
    It usually happens when calling "deleteLater()" on a null pointer, but given the stack trace (see below) I don't think this is something in my code, is it a known Qt regression?
    I see in the release notes the following item which could be related: * [QTBUG-65712] Improved performance of QObject::deleteLater.
    Or is the new implementation bringing up old bugs in my code?

    Stack trace: https://imgur.com/9mYCi4f
    Called from "QSoundEffect soundEffect.setSource(QUrl::fromLocalFile(fi.absoluteFilePath()));"


  • Qt Champions 2017

    Please post the whole stack trace.



  • 1   QMessageLogger::warning                                                                                                            qlogging.cpp              582 
    2   QCoreApplication::postEvent                                                                                                        qcoreapplication.cpp      1440 
    3   QObject::deleteLater                                                                                                               qobject.cpp               2168 
    4   QSampleCache::loadingRelease                                                                                                       qsamplecache_p.cpp        144
    5   QSample::loadIfNecessary                                                                                                           qsamplecache_p.cpp        292 
    6   QSampleCache::requestSample                                                                                                        qsamplecache_p.cpp        189 
    7   QSoundEffectPrivate::setSource                                                                                                     qsoundeffect_qaudio_p.cpp 136  
    8   QSoundEffect::setSource                                                                                                            qsoundeffect.cpp          176 
    9   Sound::Sound                                                                                                                       Sound.cpp                 32
    

    Where Sound.cpp:32 is "soundEffect.setSource(QUrl::fromLocalFile(fi.absoluteFilePath()));"


  • Qt Champions 2017

    This is not the whole stack trace, there must be more, ultimately ending up in main() or the thread main function.



  • 1  QMessageLogger::warning                                                                                                            qlogging.cpp                   582  0x6928f878     
    2  QCoreApplication::postEvent                                                                                                        qcoreapplication.cpp           1440 0x6943236b     
    3  QObject::deleteLater                                                                                                               qobject.cpp                    2168 0x69452cd3     
    4  QSampleCache::loadingRelease                                                                                                       qsamplecache_p.cpp             144  0x5a84254a     
    5  QSample::loadIfNecessary                                                                                                           qsamplecache_p.cpp             292  0x5a8427c2     
    6  QSampleCache::requestSample                                                                                                        qsamplecache_p.cpp             189  0x5a843492     
    7  QSoundEffectPrivate::setSource                                                                                                     qsoundeffect_qaudio_p.cpp      136  0x5a847dc1     
    8  QSoundEffect::setSource                                                                                                            qsoundeffect.cpp               176  0x5a840f1e     
    9  Sound::Sound                                                                                                                       Sound.cpp                      32   0x10aaf5b      
    10 ***                                                                                                ***           19   0x12f4995      
    11 ***                                                                                                     ***             45   0x12f7ba9      
    12 ***                                                                                                ***             1326 0x127c04f      
    13 ***                                                                                                         ***             1145 0x127b7ea      
    14 QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<QString>, void, void (***:: *)(QString const&)>::call qobjectdefs_impl.h             136  0x16e0dd5      
    15 QtPrivate::FunctionPointer<void (***:: *)(QString const&)>::call<QtPrivate::List<QString>, void>                        qobjectdefs_impl.h             169  0x16fa3af      
    16 QtPrivate::QSlotObject<void (***:: *)(QString const&), QtPrivate::List<QString>, void>::impl                            qobjectdefs_impl.h             398  0x16e8712      
    17 QtPrivate::QSlotObjectBase::call                                                                                                   qobjectdefs_impl.h             378  0x694556ad     
    18 QMetaObject::activate                                                                                                              qobject.cpp                    3750 0x694556ad     
    19 QMetaObject::activate                                                                                                              qobject.cpp                    3629 0x69455b70     
    20 ***                                                                                                     moc_***.cpp      179  0x13d08fe      
    21 ***                                                                                            ***          260  0x10f1d78      
    22 ***:qt_static_metacall                                                                                              moc_***.cpp      114  0x13d064f      
    23 QMetaObject::activate                                                                                                              qobject.cpp                    3767 0x69455852     
    24 QMetaObject::activate                                                                                                              qobject.cpp                    3629 0x69455b70     
    25 QAbstractButton::clicked                                                                                                           moc_qabstractbutton.cpp        308  0x235dc797     
    26 QAbstractButtonPrivate::emitClicked                                                                                                qabstractbutton.cpp            414  0x235dc9b2     
    27 QAbstractButtonPrivate::click                                                                                                      qabstractbutton.cpp            407  0x235ddf50     
    28 QAbstractButton::mouseReleaseEvent                                                                                                 qabstractbutton.cpp            1011 0x235de1f1     
    29 QWidget::event                                                                                                                     qwidget.cpp                    8897 0x23529590     
    30 QAbstractButton::event                                                                                                             qabstractbutton.cpp            968  0x235df3ac     
    31 QPushButton::event                                                                                                                 qpushbutton.cpp                682  0x2366cf9c     
    32 QApplicationPrivate::notify_helper                                                                                                 qapplication.cpp               3732 0x234e8326     
    33 QApplication::notify                                                                                                               qapplication.cpp               3208 0x234ef94d     
    34 QCoreApplication::notifyInternal2                                                                                                  qcoreapplication.cpp           1050 0x6942c1c4     
    35 QCoreApplication::sendSpontaneousEvent                                                                                             qcoreapplication.h             237  0x234eedeb     
    36 QApplicationPrivate::sendMouseEvent                                                                                                qapplication.cpp               2709 0x234eedeb     
    37 QWidgetWindow::handleMouseEvent                                                                                                    qwidgetwindow.cpp              661  0x2353ed74     
    38 QWidgetWindow::event                                                                                                               qwidgetwindow.cpp              280  0x23540ee7     
    39 QApplicationPrivate::notify_helper                                                                                                 qapplication.cpp               3732 0x234e8326     
    40 QApplication::notify                                                                                                               qapplication.cpp               3104 0x234ef66e     
    41 QCoreApplication::notifyInternal2                                                                                                  qcoreapplication.cpp           1050 0x6942c1c4     
    42 QCoreApplication::sendSpontaneousEvent                                                                                             qcoreapplication.h             237  0x2f8ad0b8     
    43 QGuiApplicationPrivate::processMouseEvent                                                                                          qguiapplication.cpp            1960 0x2f8ad0b8     
    44 QGuiApplicationPrivate::processWindowSystemEvent                                                                                   qguiapplication.cpp            1741 0x2f8aeddd     
    45 QWindowSystemInterface::sendWindowSystemEvents                                                                                     qwindowsysteminterface.cpp     984  0x2f8910f3     
    46 QWindowsGuiEventDispatcher::sendPostedEvents                                                                                       qwindowsguieventdispatcher.cpp 82   0xe75d6e79     
    47 qt_internal_proc                                                                                                                   qeventdispatcher_win.cpp       237  0x6947f917     
    48 USER32!CallWindowProcW                                                                                                                                                 0x7ffb08edbc50 
    49 USER32!DispatchMessageW                                                                                                                                                0x7ffb08edb5cf 
    50 QEventDispatcherWin32::processEvents                                                                                               qeventdispatcher_win.cpp       629  0x6947f07e     
    51 QWindowsGuiEventDispatcher::processEvents                                                                                          qwindowsguieventdispatcher.cpp 74   0xe75d6e57     
    52 QEventLoop::processEvents                                                                                                          qeventloop.cpp                 134  0x6942a83b     
    53 QEventLoop::exec                                                                                                                   qeventloop.cpp                 212  0x6942ac59     
    54 QCoreApplication::exec                                                                                                             qcoreapplication.cpp           1338 0x69433a9a     
    55 QGuiApplication::exec                                                                                                              qguiapplication.cpp            1687 0x2f8a4df5     
    56 QApplication::exec                                                                                                                 qapplication.cpp               2917 0x234e8208     
    57 main                                                                                                                               ***.cpp                    303  0x403288
    

    I've scrubbed the internal class names, company policy, sorry, but they should not be needed anyway.


  • Qt Champions 2017

    File a bug report. Here's the relevant code (dev branch):

    void QSampleCache::loadingRelease()
    {
        QMutexLocker locker(&m_loadingMutex);
        m_loadingRefCount--;
        if (m_loadingRefCount == 0) {
            if (m_loadingThread.isRunning()) {
                m_networkAccessManager->deleteLater();
                m_networkAccessManager = nullptr;
                m_loadingThread.exit();
            }
        }
    }
    

    It probably is a bug in the multimedia module itself, I'd say m_networkAccessManager is null - probably never initialized for a local file. But then, for whatever reason, the m_networkAccessManager is deleted after loading has finished.
    And to be frank it seems rather odd that someone would use a mutex to synchronize a simple counter ... not a semaphore, not an atomic int, but a mutex ...

    PS.
    After some more thorough looking at it, I see why the mutex's there. Still I continue to think it's a bug in the multimedia module. You could see if any changes were made between the two mentioned Qt versions, as with the QSampleCache::networkAccessManager() creating the NAM on demand, it is possible that it was never created and then a deleteLater was invoked on it.





  • Hello! Can you please explain how did you manage to get this call stack? Where did you put breakpoint? I had the same problem. I was trying to locate the exact place where the warning was issued, but with no success.
    Do you have to install additional tools, or is it possible with Qt Creator and installed debugger only?


  • Qt Champions 2017

    Hi @AlexZ,

    usually it's enough to debug a debug build with Creator. On a crash, the debugger will jump in and provide you with the stacktrace.



  • @aha_1980 Thank you very much for the response. But what if the program doesn't crash? I only create QSoundEffect instance in main(), initialize it with correct path, play it and that's all. The program doesn't crash, but outputs to the console "QCoreApplication::postEvent: Unexpected null receiver" and exits with code 0. Is there any way to locate where this warning was issued?


  • Qt Champions 2017

    Hi @AlexZ,

    I've searched for the string you gave me and found it in qcoreapplication.cpp around line 1146:

    static bool doNotify(QObject *receiver, QEvent *event)
    {
        if (receiver == 0) {                        // serious error
            qWarning("QCoreApplication::notify: Unexpected null receiver");
            return true;
        }
    
    #ifndef QT_NO_DEBUG
        QCoreApplicationPrivate::checkReceiverThread(receiver);
    #endif
    
        return receiver->isWidgetType() ? false : QCoreApplicationPrivate::notify_helper(receiver, event);
    }
    

    If you have the Qt sources installed or build Qt yourself from sources, you can try to set a breakpoint there to get the stack.

    Regards



  • @AlexZ Using asan in my case, and crashing on warnings.

    I've made a patch here, still some issue to solve when I find the time.
    https://codereview.qt-project.org/#/c/222608/


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.