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. Debug and Release execution issues

Debug and Release execution issues

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 645 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
    steveq
    wrote on last edited by
    #1

    Hey Gurus,
    I have written a program that is similar to Facebook Messenger. It’s a chat program. The program consists of a server and a client.
    I have an issue which has stumped me. The software is running on my PC.
    Up until now everything has been running very well. Over the last couple of days, I have done some fairly major changes to some sections of the code. Now all of a sudden I have this weird issue.
    If I run the server compiled in debug mode, it works perfectly. Clients can connect to it and the program runs flawlessly.
    If I run the server compiled in release mode, it launches and looks to be running fine, but it won't accept any incoming connections. In fact it doesn't seem to even know there is an incoming connection.
    It's not firewall issues. In my test, the client and server were both running on the same machine. Debug works, release won't work.
    It gets better though...
    I have cross compiled my software to run on my Raspberry Pi. When my server is running day to day, it runs on the Raspberry Pi. The exact same code compiled in release mode on the Raspberry Pi works flawlessly!

    I did a Clean All, Run Qmake, Rebuild All, but no difference.

    I really have no idea where to start looking for this bug.

    Why will the debug version work and the release version not work on my PC, but the release version will work on my Raspberry Pi?

    I'd really appreciate it if someone could please point me in the right direction on how to solve this.

    Thanks so much,

    Steve Q. :-)

    JonBJ 1 Reply Last reply
    0
    • S steveq

      Hey Gurus,
      I have written a program that is similar to Facebook Messenger. It’s a chat program. The program consists of a server and a client.
      I have an issue which has stumped me. The software is running on my PC.
      Up until now everything has been running very well. Over the last couple of days, I have done some fairly major changes to some sections of the code. Now all of a sudden I have this weird issue.
      If I run the server compiled in debug mode, it works perfectly. Clients can connect to it and the program runs flawlessly.
      If I run the server compiled in release mode, it launches and looks to be running fine, but it won't accept any incoming connections. In fact it doesn't seem to even know there is an incoming connection.
      It's not firewall issues. In my test, the client and server were both running on the same machine. Debug works, release won't work.
      It gets better though...
      I have cross compiled my software to run on my Raspberry Pi. When my server is running day to day, it runs on the Raspberry Pi. The exact same code compiled in release mode on the Raspberry Pi works flawlessly!

      I did a Clean All, Run Qmake, Rebuild All, but no difference.

      I really have no idea where to start looking for this bug.

      Why will the debug version work and the release version not work on my PC, but the release version will work on my Raspberry Pi?

      I'd really appreciate it if someone could please point me in the right direction on how to solve this.

      Thanks so much,

      Steve Q. :-)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @steveq
      In the time it took you to type this, you could have put a couple of judicious log-to-file messages and compiled for Release mode on PC to verify e.g.

      If I run the server compiled in release mode, it launches and looks to be running fine, but it won't accept any incoming connections. In fact it doesn't seem to even know there is an incoming connection.

      One guess is that they do all still work, and somehow the Release one is not working because there is still some artefact left over from previous compilations, or wrong library versions, or something. Scrub hard/solid disk vigorously with soap just in case :) Or, you'll wake up tomorrow, perhaps relink, and miraculously it will work OK after all.

      Now assume there is some bug in your code. I wouldn't read too much into "but it works in Release mode on some other machine/environment". Doesn't mean it isn't a bug which does show up on original PC, you may just be getting away with it on RPi, as you are when compiled Debug.

      It won't help you track it down much, but one of the commonest reasons in that in Release build uninitialized memory really does contain "random" content, whereas it might be initialized to 0s in Debug. Bugs show up when something happens to have non-zero content. But it could be anything --- timings differing Release vs Debug can mean things happen closer together. If your server is using threads(?), that's nasty for only showing up bugs when e.g. running faster in Release.

      Since you can't repro under Debug, do yourself a favor and put in some log-to-file statements. You could at least confirm whether the bad server isn't even listening.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        steveq
        wrote on last edited by
        #3

        Thanks @JonB for your comments!

        I'll go looking for random content in my variables and I'll do your suggestion of commenting into a log file.

        It was late last night when I threw my hands up in disgust! Hopefully the fresh light of a new day will bring with it an epiphany and my programming woes will all but disappear.

        Thanks again!

        Steve Q. :-)

        JonBJ 1 Reply Last reply
        0
        • S steveq

          Thanks @JonB for your comments!

          I'll go looking for random content in my variables and I'll do your suggestion of commenting into a log file.

          It was late last night when I threw my hands up in disgust! Hopefully the fresh light of a new day will bring with it an epiphany and my programming woes will all but disappear.

          Thanks again!

          Steve Q. :-)

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @steveq
          In another similar new post, user @JKSH has just posted a refernce to https://exceptionshub.com/program-only-crashes-as-release-build-how-to-debug.html. This includes among its suggestions the issue of unitialized variables behaving differently under Release vs Debug, but also other common ones. And some possible tools to help. You should take a look.

          S 1 Reply Last reply
          2
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            Are you using SSL to secure the transmissions?

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            S 1 Reply Last reply
            0
            • JonBJ JonB

              @steveq
              In another similar new post, user @JKSH has just posted a refernce to https://exceptionshub.com/program-only-crashes-as-release-build-how-to-debug.html. This includes among its suggestions the issue of unitialized variables behaving differently under Release vs Debug, but also other common ones. And some possible tools to help. You should take a look.

              S Offline
              S Offline
              steveq
              wrote on last edited by
              #6

              @JonB thanks again. That’s an interesting read. It appears an uninitialised variable is most likely my issue! This is in spite of the fact that I am anal about this sort of thing. Hopefully it is something this simple.
              Cheers!

              1 Reply Last reply
              0
              • VRoninV VRonin

                Are you using SSL to secure the transmissions?

                S Offline
                S Offline
                steveq
                wrote on last edited by
                #7

                @VRonin I encrypt data in both directions to and from the server, but... I didn't use QT's SSL classes as I wasn’t aware of their existence at the time. Doh! Still it works (apart from my release issue) . :-)

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  steveq
                  wrote on last edited by
                  #8

                  I found a stray uninitialised variable that I had missed, it appears to have been the culprit. It seems to be running again now. :-)
                  Thanks for your help guys. :-)

                  1 Reply Last reply
                  1

                  • Login

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