Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Make produces sometimes broken executables
QtWS25 Last Chance

Make produces sometimes broken executables

Scheduled Pinned Locked Moved Qt Creator and other tools
12 Posts 5 Posters 5.3k Views
  • 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.
  • S Offline
    S Offline
    s.frings
    wrote on last edited by
    #1

    Hello,
    I noticed that make sometimes produces bad executables after applying small changes to cpp files. The generated program crashes sporadically at some points. The problem is reprodceable until I clean the build directory and make the executable again.

    Is that a well-known issue or can I do something to fix it?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      anselmolsm
      wrote on last edited by
      #2

      Difficult to say what's the problem. Try to create a simple test case, it can be useful to understand what is happenning and, if it's a Qt bug, this test will became an important part of a bugreport.

      Anselmo L. S. Melo (anselmolsm)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        danilocesar
        wrote on last edited by
        #3

        Are you using qmake? If your dependency tree is right, it shouldn't happen.

        I've saw cases when adding Q_OBJECT macro after the first compiling produces some mistakes related with moc and metaobject methods. But it will not affect the binary since your code will not compile.

        Can you reproduce this problem and write down the steps here?

        <a href="http://www.danilocesar.com">Danilo Cesar Lemes de Paula</a>
        Software Engineer

        1 Reply Last reply
        0
        • S Offline
          S Offline
          s.frings
          wrote on last edited by
          #4

          Yes I use qmake and then make (through the qtcreator IDE). No, i cannot reproduce it, because that problem occurs only randomly. But it happend about 4 times this week. I will monitor it longer.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lyuts
            wrote on last edited by
            #5

            Are you sure you haven't messed up the stack in your program? Could you show us the backtrace?

            I'm a rebel in the S.D.G.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              s.frings
              wrote on last edited by
              #6

              I will need to find a way to reproduce the problem. Unfortunately (or happily) it did not happen sind I wrote this topic, and I compiled a lot since then.

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lyuts
                wrote on last edited by
                #7

                One of the reasons for undetermined behavior of an application might be uninitialized variables. Try to check them in your source code. Some time ago I used valgrind for that, it gives an error if it bumps into uninitialized variable.

                I'm a rebel in the S.D.G.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  s.frings
                  wrote on last edited by
                  #8

                  @lyuts
                  Thanks for your hint. I compared the current source with the old one where the problem occured several times and I think I found the problem cause. Under certain conditions, the application deleted a single object twice.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    s.frings
                    wrote on last edited by
                    #9

                    The problem occured again today. I am sure that the program does not mess up stack and there are no uninitilized variables anymore. The only thing that I changes was, that I placed a preprocessor directive around a debug logging statement, so it is only enabled when I compile the debug version.

                    After compilation, the program crashed repeatedly at the same point. I klicked on the rebuild link, which did not help. Then I inserted lots of additional debug messages to find the exact point because the debugger does not start properly (which is a well-known bug in the current release). But none of these new messages appeard, altough the program was obviously executing the related part of code.

                    So it was obvious that the make did not update the *.o file anymore. I selected the cleanup function in QT Creator, but some few files have been left in the build directory. After recompilation, the problem was still there. The I deleted the build directory manually, and voilla - problem was gone and the new debug messages are also visible now. The program does not crash anymore.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      lyuts
                      wrote on last edited by
                      #10

                      Could you paste the backtrace?

                      I'm a rebel in the S.D.G.

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        tbscope
                        wrote on last edited by
                        #11

                        It is normal behaviour.

                        Whenever you make a change that requires the preprocessing of files, you need to rebuild at least that part of the source tree.

                        Always rebuild the complete source, or, split a big source tree up in managable parts.

                        Edit: to make this a little bit clearer:
                        Yes, the .cpp or .h file changed. It gets recompiled. However, it does not get preprocessed again automatically.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          s.frings
                          wrote on last edited by
                          #12

                          @lyuts
                          How can I create a backtrace an what is it good for? (Please remember that I cannot use the Debugger in QT Creator with my application, it is not able to start the application, so doing something on the command-line would be more helpful).

                          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