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. Optimization in debug mode using or not debugging
Forum Updated to NodeBB v4.3 + New Features

Optimization in debug mode using or not debugging

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

    Hi,

    recently I have imported in my project a particular algorithm that was already written on an old project. After a lot of testing where I only used the debugger I tried to run the program without it. What I noticed is that it's behaviour is different: when I use the debugger everything works perfectly but when I simply run the program the output is different. It looks like there is a sort of optimization if I run without the debugger.
    For both I'am workoing on debug mode, I am not talking about debug and release mode.

    Is it something somebody has already run into? Do you have any advice?

    I'm working on windows 10 using Qt 5.9.1 MinGW 32 bit.

    jsulmJ 1 Reply Last reply
    0
    • D davidesalvetti

      Hi,

      recently I have imported in my project a particular algorithm that was already written on an old project. After a lot of testing where I only used the debugger I tried to run the program without it. What I noticed is that it's behaviour is different: when I use the debugger everything works perfectly but when I simply run the program the output is different. It looks like there is a sort of optimization if I run without the debugger.
      For both I'am workoing on debug mode, I am not talking about debug and release mode.

      Is it something somebody has already run into? Do you have any advice?

      I'm working on windows 10 using Qt 5.9.1 MinGW 32 bit.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @davidesalvetti said in Optimization in debug mode using or not debugging:

      output is different

      In what way? It is hard to guess without more information.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply
      2
      • jsulmJ jsulm

        @davidesalvetti said in Optimization in debug mode using or not debugging:

        output is different

        In what way? It is hard to guess without more information.

        D Offline
        D Offline
        davidesalvetti
        wrote on last edited by davidesalvetti
        #3

        @jsulm sorry for not mention that.

        I have a QVector array that is filled inside the algorithm. If I launch the app with the debugger I get some values that I know are correct. But when I run it without the debugger I get a lot of values more. Let's say with debugger I get 3 values that are correct and without it I get 12 values that are not correct.
        So I thought that there must be a difference when I run a program with debugger and when I run it without it.
        Unfortunately I cannot put the algorithm here for a matter of copyright, I know that this is not so much...

        Is there some optimization when debugging or some other option that is different and that i can check? Honestly it's not the first time that variables behave different when in debugging.

        D 1 Reply Last reply
        0
        • D davidesalvetti

          @jsulm sorry for not mention that.

          I have a QVector array that is filled inside the algorithm. If I launch the app with the debugger I get some values that I know are correct. But when I run it without the debugger I get a lot of values more. Let's say with debugger I get 3 values that are correct and without it I get 12 values that are not correct.
          So I thought that there must be a difference when I run a program with debugger and when I run it without it.
          Unfortunately I cannot put the algorithm here for a matter of copyright, I know that this is not so much...

          Is there some optimization when debugging or some other option that is different and that i can check? Honestly it's not the first time that variables behave different when in debugging.

          D Offline
          D Offline
          davidesalvetti
          wrote on last edited by
          #4

          Any suggestion?

          jsulmJ 1 Reply Last reply
          0
          • D davidesalvetti

            Any suggestion?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #5

            @davidesalvetti No, without source code I can't tell.
            Usually such issues are caused by not initialised variables (behaviour is different between debug and release builds). So, check your code for such issues.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              Since you mention its always a debug build, then the normal suspects between release/debug does not apply.
              However, debugging can alter the normal timings of the app so it can be related to anything you do asynchronous like with a timer or thread.

              1 Reply Last reply
              2
              • gde23G Offline
                gde23G Offline
                gde23
                wrote on last edited by
                #7

                You mention that " with debugger I get 3 values that are correct and without it I get 12 values that are not correct." Does this mean that the algorithm always outputs a certain fraction of values that are correct and the rest is wrong? If yes, where does the randomness come from? Is there some random-call in there or indirectly from a race condition or something?

                D 1 Reply Last reply
                0
                • gde23G gde23

                  You mention that " with debugger I get 3 values that are correct and without it I get 12 values that are not correct." Does this mean that the algorithm always outputs a certain fraction of values that are correct and the rest is wrong? If yes, where does the randomness come from? Is there some random-call in there or indirectly from a race condition or something?

                  D Offline
                  D Offline
                  davidesalvetti
                  wrote on last edited by
                  #8

                  @gde23 thanks for your answer.

                  I don't have threads or QTimer so I would exclude race conditions. The algorithm is executed in the main thread and is executed from the beginning till the end, that's why it's really strange and I can't understand this difference between using the debugger or not.

                  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