Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Application crash on emit signal
Qt 6.11 is out! See what's new in the release blog

Application crash on emit signal

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dwidmann
    wrote on last edited by
    #1

    I have a strange issue with one of my projects currently, where an application crashes on emitting a signal. I've never had anything like this happen before, so I have absolutely no idea where or how to start with debugging this.

    • I'm currently using Qt 6.2.2 (from source, debug build)
    • The relevant signal is being emitted from an object that is an instance of a plugin which indirectly inherits from QObject, QRunnable, and a plugin interface (in that order) that was built with the same environment/options/etc. I load it and then run the runnable in another thread via QThreadPool::start()
    • The crash really does happen on emit. It doesn't matter whether it's connected to a slot or not. Particularly, the last few lines listed in the debugger when it crashes are:
      function | file:line | linecontents
      DummyWorkerSS::run | dummyworkerss.cpp:35 | Q_EMIT signal_taskFinished(_vmap);
      DummyWorkerSS::signal_taskFinished | moc_dummyworkerss.cpp:142 | QMetaObject::activate(this, &staticMetaObject, 0, _a);
      QMetaObject::activate | qobject.cpp:3968 | --- (where is that file?)
      doActivate<false> | qobject.cpp:3788 | ---

    What are the likely suspects / how should I go about tracking this problem down?

    1 Reply Last reply
    0
    • A.A.SEZENA Offline
      A.A.SEZENA Offline
      A.A.SEZEN
      wrote on last edited by
      #3

      You may be trying to access a memory point that no longer exists.

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Please provide some code on how you call it, what you're doing.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • A.A.SEZENA Offline
          A.A.SEZENA Offline
          A.A.SEZEN
          wrote on last edited by
          #3

          You may be trying to access a memory point that no longer exists.

          1 Reply Last reply
          0
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #4

            @A-A-SEZEN said in Application crash on emit signal:

            You may be trying to access a memory point that no longer exists.

            I think this is probably closest to the truth of the matter. Debugging multi-threaded apps is a PITA, and I've found source level debuggers to be quite limited in that regard. Thread syncronization ie does the thread exist and in a state you expect when you you try to communicate with/thru it...is often hard to determine. You should resort to some good ole fashion cerr output debugging to track down where this crash really occurs. the cause probably preceded the emit where you think it is happening...and it the emit trying to deliver to a thread that no longer exist and the real crash is the nonexistent receiver?

            The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dwidmann
              wrote on last edited by
              #5

              It took me a while to get to the bottom of this because the error I was getting was neither straightforward (nor consistent after I switched to a debug build), but here is, in essence, what happened:
              I was keeping track of references to the runners with QSharedPointers. I had popped the reference off the list, put it in a QVariant, and passed it along with the runner. Evidently, this didn't prevent the reference count from dropping to zero, and the object was deleted some time shortly after the thread started executing. It was just a dummy object for testing, so it managed to complete execution before the objects' deletion, but wasn't able to live long enough to emit the signal.

              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved