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. Why emitting signal can cause a segmentation fault?
Forum Updated to NodeBB v4.3 + New Features

Why emitting signal can cause a segmentation fault?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.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.
  • C Offline
    C Offline
    CuriousPan
    wrote on last edited by
    #1

    Working on my project I got stuch with the following issue: emitting one signal results in segmentation fault. I googled the Internet and it turned out that it can the case that objects emitting signals might be not initialised, but it's not true in my case (at least from what I see). What can be the potential problem?

    P.S. I'm connecting signal of a member pointer object (which is getting assigned using initialiser list) to one of the slots of the object so there's no way these things can be uninitialised.

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

      As always - use a debugger and take a look where it crashes, fix it.

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

      C 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        As always - use a debugger and take a look where it crashes, fix it.

        C Offline
        C Offline
        CuriousPan
        wrote on last edited by CuriousPan
        #3

        @Christian-Ehrlicher, yes, that's what I did. I'll be honest with you, I'm not that experienced in debugging, but during debugging process the program crashes at line 'emit signal()' and debugger directs me to this:

              _GLIBCXX_ALWAYS_INLINE __int_type
              load(memory_order __m = memory_order_seq_cst) const noexcept
              {
        	memory_order __b = __m & __memory_order_mask;
        	__glibcxx_assert(__b != memory_order_release);
        	__glibcxx_assert(__b != memory_order_acq_rel);
        
        	return __atomic_load_n(&_M_i, __m);
              }
        
        JonBJ 1 Reply Last reply
        0
        • M Offline
          M Offline
          mchinand
          wrote on last edited by
          #4

          Look at the previous lines in the stack trace to see where it is in your code when the segfault happens. Also, post your code where you emit your signal and of the slot that it's connected to.

          1 Reply Last reply
          2
          • C CuriousPan

            @Christian-Ehrlicher, yes, that's what I did. I'll be honest with you, I'm not that experienced in debugging, but during debugging process the program crashes at line 'emit signal()' and debugger directs me to this:

                  _GLIBCXX_ALWAYS_INLINE __int_type
                  load(memory_order __m = memory_order_seq_cst) const noexcept
                  {
            	memory_order __b = __m & __memory_order_mask;
            	__glibcxx_assert(__b != memory_order_release);
            	__glibcxx_assert(__b != memory_order_acq_rel);
            
            	return __atomic_load_n(&_M_i, __m);
                  }
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @CuriousPan
            Need to emphsize what @mchinand has written: you need to look around the debugger's windows/panes till you find the Stack Trace one. It shows which functions were calling which when the crash happened. Look back up till you find it's telling you a line in your code, look at that.

            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