Debug/Release problem?
-
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
-
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
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. ** -
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. **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
-
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. **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!
-
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!
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!
-
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!
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
-
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!
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?
-
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!
Defintely not a solution. Have a look "Surviving the Release Version". Neville Franks, Author of ED for Windows. www.getsoft.com