-2

I have a process which I've been building until today in debug mode and it behaved just like I expected it to behave. If an exception was thrown I debugged it and fixed the problem.
Now I built my process in release mode, but it throws exceptions that it didn't when I ran it in debug mode.
I'd like to debug it, but in debug mode the compiler protected the memory and other stuff, I can't catch those execptions.

Is there a way to make the debug mode throw the exceptions that the release build would throw?

Idov
  • 5,006
  • 17
  • 69
  • 106
  • what exception it throws ? – qwr May 11 '13 at 15:29
  • mainly "Access violation" exceptions. – Idov May 11 '13 at 15:31
  • Change the project properties for the Release build to generate a PDB, then you can at least analyse a dump and get a useful call stack. – Roger Rowland May 11 '13 at 15:32
  • One of the biggest problems is that I can't rely on the values of the variables I see when trying to debug the release version since they tend to be incorrect. – Idov May 11 '13 at 15:33
  • DO you know in what area it occurs ? if not try to log suspicious areas . – qwr May 11 '13 at 15:34
  • In some cases I do and in some cases I don't... – Idov May 11 '13 at 15:38
  • log your code with simply printf and see . at least you would know on which function or block it occur . then you can post that piece of code – qwr May 11 '13 at 15:38
  • What are the memory values of the access violation? near 0x00000000, 0xfeeefeee, 0xcccccccc or something else entirely? – Casey May 11 '13 at 15:39
  • In one case it's a 0x00000000, In another case it crashes when I try to delete a buffer that I dynamicaaly allocated. – Idov May 11 '13 at 15:41
  • Could you post your code where you are getting it ? check for double deletion or deletion pointer without initializing it , or error can be other place too . it be easy if you post your code – qwr May 11 '13 at 15:43
  • No, I'm afraid it's too much code... :/ – Idov May 11 '13 at 15:47
  • check buffer that you allocating ; assign it always NULL before allocating, and try to see that there cannot be any double deletion ,or after delete aggain assing it to null , or see if something not changing its value , – qwr May 11 '13 at 15:49
  • hmmm... the Access Violation points at some "random" address.... – Idov May 11 '13 at 16:05
  • please post a piece of code where u getting it – qwr May 11 '13 at 16:19
  • Compile your release build with /Zi - then you can debug the release build also. – user93353 May 11 '13 at 18:23

2 Answers2

0

Something of a shot in the dark, but a standard difference between debug and release builds is that all variables in a debug build are initialized regardless of whether you actually do this in the code, whereas in release mode they aren't. So go through your code and make sure every variable is initialized at the point of declaration, and see if that solves the problem.

Matt Phillips
  • 9,465
  • 8
  • 44
  • 75
0

Hmmm... I think I got it.
My process loads other DLLs as plugins.
I noticed that when I run my process in Release mode and load DLLs built in Debug mode - or the other way around - it crashes.

I guess some objects imported from the plugins have different layout or size in release or debug mode.

If anyone can give a better explanation to this, it will be great :)

Idov
  • 5,006
  • 17
  • 69
  • 106