Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Receving Seg Fault in Qthread when SIGINT Signal arrives

    General and Desktop
    4
    9
    1847
    Loading More Posts
    • 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
      mbajaria last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • M
          mbajaria last edited by 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

          kshegunov 1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • M
              mbajaria last edited by

              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 Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • M
                  mbajaria last edited by

                  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?

                  JKSH 1 Reply Last reply Reply Quote 0
                  • JKSH
                    JKSH Moderators @mbajaria last edited by

                    @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 Reply Quote 0
                    • kshegunov
                      kshegunov Moderators @mbajaria last edited by

                      @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 Reply Quote 0
                      • First post
                        Last post