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. Program SegFaults but doesn't give me any information

Program SegFaults but doesn't give me any information

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.9k 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.
  • R Offline
    R Offline
    RBrNx277
    wrote on last edited by
    #1

    Hi there, I am currently having a problem where my program will produce a SegFault. I understand that this is normally from accessing memory that the program shouldn't be. I am currently trying to debug where the SegFault is occuring but I have a fairly large codebase, and when the QT Debugger tells me I have a SegFault, it doesn't seem to show me the stack trace anywhere to show what function caused the SegFault, nor does it break on the line that SegFaulted, as you can see here.

    Is there any way for me to find out the line number or function in which the SegFault occured?

    Thanks, RBrNx

    kshegunovK 1 Reply Last reply
    0
    • R RBrNx277

      Hi there, I am currently having a problem where my program will produce a SegFault. I understand that this is normally from accessing memory that the program shouldn't be. I am currently trying to debug where the SegFault is occuring but I have a fairly large codebase, and when the QT Debugger tells me I have a SegFault, it doesn't seem to show me the stack trace anywhere to show what function caused the SegFault, nor does it break on the line that SegFaulted, as you can see here.

      Is there any way for me to find out the line number or function in which the SegFault occured?

      Thanks, RBrNx

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

      @RBrNx277
      What debug information would you be expecting from a release build?

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RBrNx277
        wrote on last edited by RBrNx277
        #3

        @kshegunov That's true, I didn't think about that. Unfortunately I cannot get the SegFault to occur in the Debug version, the program simply hangs and I then have to force close it after it becomes unresponsive.

        EDIT: Please ignore me, it seems to give me the SegFault in the Debug Version now.
        EDIT: It's back to not showing again.

        kshegunovK 1 Reply Last reply
        0
        • R RBrNx277

          @kshegunov That's true, I didn't think about that. Unfortunately I cannot get the SegFault to occur in the Debug version, the program simply hangs and I then have to force close it after it becomes unresponsive.

          EDIT: Please ignore me, it seems to give me the SegFault in the Debug Version now.
          EDIT: It's back to not showing again.

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

          @RBrNx277

          Unfortunately I cannot get the SegFault to occur in the Debug version, the program simply hangs and I then have to force close it after it becomes unresponsive.

          Fix that first, then try in release mode. If you're using threads, it might be the synchronization, because it sounds like a race condition happening.

          Read and abide by the Qt Code of Conduct

          R 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @RBrNx277

            Unfortunately I cannot get the SegFault to occur in the Debug version, the program simply hangs and I then have to force close it after it becomes unresponsive.

            Fix that first, then try in release mode. If you're using threads, it might be the synchronization, because it sounds like a race condition happening.

            R Offline
            R Offline
            RBrNx277
            wrote on last edited by RBrNx277
            #5

            @kshegunov I realised I had some extra code still running in my program that I had added and forgot to remove. Now that my code is back to the way it used to be, in Debug mode my program seems to function no problem (see below), however as soon as I run the code in Release mode it segfaults almost straight away.

            There is no threading in my code at the moment.

            EDIT:
            Debug Mode - Run: Program will hang and become unresponsive
            Debug Mode - Start Debugging: Program has no problems at all
            Release Mode - Run: Program will crash "Program has stopped responding"
            Released Mode - Start Debugging: Program SegFaults

            kshegunovK W 2 Replies Last reply
            0
            • R RBrNx277

              @kshegunov I realised I had some extra code still running in my program that I had added and forgot to remove. Now that my code is back to the way it used to be, in Debug mode my program seems to function no problem (see below), however as soon as I run the code in Release mode it segfaults almost straight away.

              There is no threading in my code at the moment.

              EDIT:
              Debug Mode - Run: Program will hang and become unresponsive
              Debug Mode - Start Debugging: Program has no problems at all
              Release Mode - Run: Program will crash "Program has stopped responding"
              Released Mode - Start Debugging: Program SegFaults

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

              @RBrNx277
              Well, that's certainly quite strange. The only thing that I can think of currently is that some static variables are not initialized in the proper order, but still this'd be by far a long shot.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • R RBrNx277

                @kshegunov I realised I had some extra code still running in my program that I had added and forgot to remove. Now that my code is back to the way it used to be, in Debug mode my program seems to function no problem (see below), however as soon as I run the code in Release mode it segfaults almost straight away.

                There is no threading in my code at the moment.

                EDIT:
                Debug Mode - Run: Program will hang and become unresponsive
                Debug Mode - Start Debugging: Program has no problems at all
                Release Mode - Run: Program will crash "Program has stopped responding"
                Released Mode - Start Debugging: Program SegFaults

                W Offline
                W Offline
                Wurgl
                wrote on last edited by
                #7

                @RBrNx277 Maybe something like this one:
                https://forum.qt.io/topic/56274/solved-application-sometimes-crashes

                The problem here was the call to exit() which did not call the destructor of QApplication and since QApplication seems to do something with threads, these threads are cleaned up "somewhen". Sadly the order of the cleanup … however, it sometimes crashed. Maybe you have a similar problem.

                BTW: I never have seen those crashes in Qt 4, just with Qt5

                kshegunovK 1 Reply Last reply
                0
                • W Wurgl

                  @RBrNx277 Maybe something like this one:
                  https://forum.qt.io/topic/56274/solved-application-sometimes-crashes

                  The problem here was the call to exit() which did not call the destructor of QApplication and since QApplication seems to do something with threads, these threads are cleaned up "somewhen". Sadly the order of the cleanup … however, it sometimes crashed. Maybe you have a similar problem.

                  BTW: I never have seen those crashes in Qt 4, just with Qt5

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

                  @Wurgl
                  Naturally you shouldn't just terminate the process arbitrarily with exit. It's like hitting someone with a baseball bat for goodbye! Just allow the application to gracefully exit by returning the value of QApplication::exec thus allowing for the cleanup code to run. By the way you also (possibly) have a memory leak as no one is obligated to clean up your window automatically. If you want to return a specific integer to the shell, well then just call QApplication::exit with the appropriate code.

                  PS. Since you were wondering ::exit() will not clean up objects with automatic storage (i.e. stack objects), that's why the QApplication destructor is not called.

                  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