Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Debug/Release problem?

Debug/Release problem?

Scheduled Pinned Locked Moved C / C++ / MFC
helpannouncementdebuggingtutorialquestion
8 Posts 5 Posters 0 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.
  • M Offline
    M Offline
    MarkPQ
    wrote on last edited by
    #1

    Hi All. First I want to thank all the helpful people here. I've finally succeeded in writing my first decent windows program! Its a multithreaded program that gets data from a serial device! I have a bit of tidying up and error handling to do but its doing the job nicely at the moment! However I have this problem when I switch it over to release mode! I have a dll as well that I compile in release mode then run the application. Everything seems fine until I try and update a list of records available in the serial device to a listbox in my dialog. In debug mode this works perfectly, however in release mode it will only list the first record (there's about 120) at which point it kills the thread practically straight away!! Any tips or advice on how to track down whats causing the problem, or what I should look at in order to diagnose whats causing it? Thanks -Mark

    T 1 Reply Last reply
    0
    • M MarkPQ

      Hi All. First I want to thank all the helpful people here. I've finally succeeded in writing my first decent windows program! Its a multithreaded program that gets data from a serial device! I have a bit of tidying up and error handling to do but its doing the job nicely at the moment! However I have this problem when I switch it over to release mode! I have a dll as well that I compile in release mode then run the application. Everything seems fine until I try and update a list of records available in the serial device to a listbox in my dialog. In debug mode this works perfectly, however in release mode it will only list the first record (there's about 120) at which point it kills the thread practically straight away!! Any tips or advice on how to track down whats causing the problem, or what I should look at in order to diagnose whats causing it? Thanks -Mark

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Maybe you put some vital function call into assert() or ASSERT()? Tomasz Sowinski -- http://www.shooltz.com
      ** If you're going to rape, pillage and burn, be sure to do things in that order. **

      M 2 Replies Last reply
      0
      • T Tomasz Sowinski

        Maybe you put some vital function call into assert() or ASSERT()? Tomasz Sowinski -- http://www.shooltz.com
        ** If you're going to rape, pillage and burn, be sure to do things in that order. **

        M Offline
        M Offline
        MarkPQ
        wrote on last edited by
        #3

        Well I havent used any assertions directly in my code! However I was getting assertion errors in this thread at one stage but I managed to diagnose the problem and fix it! Maybe the functions I am using are doing it although I dont know why? Thanks for the tip though, it'll give me something to look for

        1 Reply Last reply
        0
        • T Tomasz Sowinski

          Maybe you put some vital function call into assert() or ASSERT()? Tomasz Sowinski -- http://www.shooltz.com
          ** If you're going to rape, pillage and burn, be sure to do things in that order. **

          M Offline
          M Offline
          MarkPQ
          wrote on last edited by
          #4

          Ok things are getting really screwey now! I located the problem in the thread where it stops. I construct a message packet to send to the serial device with a bunch of 8 bit words. These include the address of the device and the command to execute! On the first loop these values are correct but it appears to be trashing them on the 2nd. I looked at the reply from the trashed message and it was saying invalid address, implying to me that the values I was sending werent correct. To look at the values it was sending to the device I perform an itoa() conversion and post it in a message to my dialog to dispaly in a text box. It appears that if I run this conversion on the values with itoa . . . the program works fine! Playing around with different things I am getting some very odd results and other things like if statements failing, but when I check the values that the satement was checking manually it should have passed!? It sounds like I've done something I probably shouldnt have somewhere!

          M S 2 Replies Last reply
          0
          • M MarkPQ

            Ok things are getting really screwey now! I located the problem in the thread where it stops. I construct a message packet to send to the serial device with a bunch of 8 bit words. These include the address of the device and the command to execute! On the first loop these values are correct but it appears to be trashing them on the 2nd. I looked at the reply from the trashed message and it was saying invalid address, implying to me that the values I was sending werent correct. To look at the values it was sending to the device I perform an itoa() conversion and post it in a message to my dialog to dispaly in a text box. It appears that if I run this conversion on the values with itoa . . . the program works fine! Playing around with different things I am getting some very odd results and other things like if statements failing, but when I check the values that the satement was checking manually it should have passed!? It sounds like I've done something I probably shouldnt have somewhere!

            M Offline
            M Offline
            MarkPQ
            wrote on last edited by
            #5

            Ok in reading MSDN I have now found out that it appears to be some optimization problem!? By putting #pragma optimize("", off) and #pragma optimize("", on) around the code for the thread in question I find that the function now works! Its got me stumped! I might just leave it at that, its a solution I suppose!

            T N 2 Replies Last reply
            0
            • M MarkPQ

              Ok things are getting really screwey now! I located the problem in the thread where it stops. I construct a message packet to send to the serial device with a bunch of 8 bit words. These include the address of the device and the command to execute! On the first loop these values are correct but it appears to be trashing them on the 2nd. I looked at the reply from the trashed message and it was saying invalid address, implying to me that the values I was sending werent correct. To look at the values it was sending to the device I perform an itoa() conversion and post it in a message to my dialog to dispaly in a text box. It appears that if I run this conversion on the values with itoa . . . the program works fine! Playing around with different things I am getting some very odd results and other things like if statements failing, but when I check the values that the satement was checking manually it should have passed!? It sounds like I've done something I probably shouldnt have somewhere!

              S Offline
              S Offline
              Sayan Mukherjee
              wrote on last edited by
              #6

              Hi, Do ensure that all variables (buffers, pointers, structure instances) are initialised in the correct context(i.e. declaration or first usage).Moreover, after you read each record from the serial device and populate the list in your application, try reinitialising the buffers which are used in the reading (from serial device) and writing(to list) operations. If the records that you are reading are of varying length then the code should take care of reading and writing the biggest record; i.e. the read/write buffers should be able to accommodate any record of any size. In my opinion, the only way to come out of this 'screwy situation' is to apply the brute force technique of debugging. You may need to put in calls to fprintf() or printf() or OutputDebugString() to monitor the steps of the code in release mode. Points mentioned above are not solutions to your problem but I sincerely hope the suggestions help. With best regards, Sayan Email:sayanmukherjee@indiatimes.com

              1 Reply Last reply
              0
              • M MarkPQ

                Ok in reading MSDN I have now found out that it appears to be some optimization problem!? By putting #pragma optimize("", off) and #pragma optimize("", on) around the code for the thread in question I find that the function now works! Its got me stumped! I might just leave it at that, its a solution I suppose!

                T Offline
                T Offline
                Tim Smith
                wrote on last edited by
                #7

                All you are doing is putting off the bug till later. You know you code is buggy. Either find it now during development or rush to fix it later after the software has been shipped. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?

                1 Reply Last reply
                0
                • M MarkPQ

                  Ok in reading MSDN I have now found out that it appears to be some optimization problem!? By putting #pragma optimize("", off) and #pragma optimize("", on) around the code for the thread in question I find that the function now works! Its got me stumped! I might just leave it at that, its a solution I suppose!

                  N Offline
                  N Offline
                  Neville Franks
                  wrote on last edited by
                  #8

                  Defintely not a solution. Have a look "Surviving the Release Version". Neville Franks, Author of ED for Windows. www.getsoft.com

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups