Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between Debug and Release executable?

Status
Not open for further replies.

golyg

Programmer
Jul 22, 2002
319
0
0
US
Hi all,
I am in the process of troubleshooting an error that is occurring in my app and the problem is that this error does not occur in the debug mode, only in the release mode.
On a side note, my error appears to be a resource issue.

Any suggestions?

specs:
XP
vs6.0

Thanks,
 
>> my error appears to be a resource issue.

Could you clarify that statement?

The highest percentage of problems with the distinction between debug and release build is cause by the use of the ASSERT() macro. Make sure you eliminate this as the cause before looking into anything else. For example if you open a file in an ASSERT macro then in release mode it will not be opened.

Code:
HANDLE handle;
ASSERT( handle = CreateFile(...));

-pete
 
The issue that made me realize this difference is that a user keeps receiving an:
"Unhandled exception in XXX.exe (ODBC32.dll): 0xC0000005: Access Violation."

When I run the release .exe of this app I can reproduce it but not when I run it in debug mode, I do not receive an error.

The reason I thought (think) its a resource issue is that some pointers are not being destroyed, now that i have inserted some 'delete' statements, this error is still there.

Still not sure though,

Thanks
 
Sometimes if optimization is used it can cause problems with certain code - Debug usually has optimization off. The first thing I do when I encounter this symptom is to turn off all optimization in Release build too and see if this resolves the issue.

More info on the error would be helpful.
 
thanks for the post.

The error message that I am getting appears to be caused by this statement:

if (m_pDBAccess->GetNextNumber(m_csRequestNumber) == FALSE)

It appears to exit the GetNextNumber function ok but then it crashes.
Again, as i stated earlier, it is tough to pin point the error since I do not receive an error in Debug mode. I have placed a afxMessageBox just before the return statement in the GetnextNumber function.


Troubles here...


Thanks

 
Sometimes you can get away with overwriting array bounds or other allocated blocks of memory in debug, but the same situation can slap you in the face in release mode....

Greetings,
Rick
 
Agree with Lazy me. Most likely than not this is the memory problem, either trying to write a forbidden block of memory or reading that. check all your pointers array boundaries...
 
you mention: "check all your pointers array boundaries"

how would I do that?


Thanks
 
Best way to do that is using the memory window. See what gets reserved and see what part is being filled with your data. It's a real pain in the butt to do this kind of work, but you'll have some idea where to look, since you pinpointed the location of the exception.

Greetings,
Rick
 
"Unhandled exception in XXX.exe (ODBC32.dll): 0xC0000005: Access Violation."

This error is caused due to the array. If you exceed the index allocated then this error is called. In the debug version do you see First Time exception handled ?

m_pDBAccess->GetNextNumber(m_csRequestNumber)

or m_csRequestNumber has not been initialised if this is a pointer that returns the next number.

 
It will be a memory error, and it may be before the code line.
Debugger automatically allocates for each array some more memory as programmed - that is the biggest difference. Release version allocated memory exactly. Then, non-initialized variables have not the same values in Debug and Release.
About m_pDBAccess->GetNextNumber(m_csRequestNumber): GetNextNumber is not a system function, and You should look exactly in the code line (and some lines before), where the error occurs.
May be You have allocated memory in one dll and try to free it in another DLL?
But all may be much easier.
May be m_pDBAccess is wrong or destroyed?
May be You have not enough rights to perform this operation with ODBC?
May be another application/thread works with/locked/not fried/closed this File/Database/Table/Resource/Variable? It occurs often by multithreading. For example, FreeLibrary() for ODBC32.dll or it's parts was called.
 
It appears to be caused by an invalid return address.
In my SQLBindCol function, I was allocating a buffer size of 8 bytes for a LONG instead of 4.
I have updated all my functions where the target type was a LONG.

Thnaks for all the help.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top