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. Receving Seg Fault in Qthread when SIGINT Signal arrives
Forum Updated to NodeBB v4.3 + New Features

Receving Seg Fault in Qthread when SIGINT Signal arrives

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 2.4k Views 3 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.
  • M Offline
    M Offline
    mbajaria
    wrote on last edited by
    #1

    For my c++ application i have created 4 qthread as follows:

    main() {

    register_sig_handler();

    a.start();
    b.start();
    c.start();
    d.start();

    a.wait();
    b.wait();
    c.wait();
    d.wait();

    Now In my "register_sig_handler" function, I have register signal as follows:
    signal(SIGINT, signal_handler);

    Now whenever I provide SIGINT using ctrl + c using keyboard. My code goes into signal handler but at the end it shows Segmentation fault(core dumped). As I ran code with gdb It looks like, error comes because of wait. So How can remove Seg fault?

    Thanks In advance.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What you are doing in your threads ?

      Can you share the stack trace you get ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mbajaria
        wrote on last edited by mbajaria
        #3

        Sorry For Late Reply

        Here Is BackTrace of My app after giving SIGINT

        Program received signal SIGINT, Interrupt.
        0x76beef38 in pthread_cond_wait () from /lib/libpthread.so.0
        (gdb) bt
        #0 0x76beef38 in pthread_cond_wait () from /lib/libpthread.so.0
        #1 0x76c96f68 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQt5Core.so.5
        #2 0x76c9600e in QThread::wait(unsigned long) () from /usr/lib/libQt5Core.so.5
        #3 0x0000e6cc in main (argc=1, argv=<optimized out>) at ../ccms_meter/src/main.cpp:44

        kshegunovK 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That doesn't explain what your threads are currently doing.

          Also, what do you do in your signal handler ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbajaria
            wrote on last edited by
            #5

            In my thread, i have socketio event handlers and i am sending and receiving events.
            In signal handler, I have only print statement which will print encountered signal number. If I doesn't call handler, than there is no issue.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you share your code ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbajaria
                wrote on last edited by
                #7

                My application has 16 files covering 4 threads. So it will be not feasible to share code. For that I have mentioned pseudo code, As per my understanding Segmentation fault is not coming because of whatever written in thread. It is coming because of thread wait condition. So is it appropriate to use thread.wait with signal handling function?

                JKSHJ 1 Reply Last reply
                0
                • M mbajaria

                  My application has 16 files covering 4 threads. So it will be not feasible to share code. For that I have mentioned pseudo code, As per my understanding Segmentation fault is not coming because of whatever written in thread. It is coming because of thread wait condition. So is it appropriate to use thread.wait with signal handling function?

                  JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #8

                  @mbajaria said in Receving Seg Fault in Qthread when SIGINT Signal arrives:

                  My application has 16 files covering 4 threads. So it will be not feasible to share code. For that I have mentioned pseudo code

                  Can you produce a small, compilable example that demonstrates this issue?

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  0
                  • M mbajaria

                    Sorry For Late Reply

                    Here Is BackTrace of My app after giving SIGINT

                    Program received signal SIGINT, Interrupt.
                    0x76beef38 in pthread_cond_wait () from /lib/libpthread.so.0
                    (gdb) bt
                    #0 0x76beef38 in pthread_cond_wait () from /lib/libpthread.so.0
                    #1 0x76c96f68 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/libQt5Core.so.5
                    #2 0x76c9600e in QThread::wait(unsigned long) () from /usr/lib/libQt5Core.so.5
                    #3 0x0000e6cc in main (argc=1, argv=<optimized out>) at ../ccms_meter/src/main.cpp:44

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #9

                    @mbajaria said in Receving Seg Fault in Qthread when SIGINT Signal arrives:

                    Here Is BackTrace of My app after giving SIGINT

                    What is the backtrace at the point when the SIGSEGV is being raised?

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    0

                    • Login

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