A buffer overrun occurs but only in debug version

I cannot debug my software because in debug version I have a message: :" A buffer overrun has occurred in [name].exe which has corrupted the program's internal state. Press break to debug the program or Continue to terminate the program.
For more details please see Help topic 'How to Debug Buffer Overrun Issues'.

After pressing 'Break' the debugger stops at    _CRT_DEBUGGER_HOOK(_CRT_DEBUGGER_GSFAILURE);
in gs_report.c which tells me nothing.

I've noticed the strange thing in the output window just before this failure:
'recorder.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcp80d.dll', Symbols loaded.
'recorder.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.1433_x-ww_5cf844d2\msvcr80.dll', No symbols loaded.
Two versions of the CRT were loaded for my program. That was not normal.
I solved the problem already but I decided to post it. The cause was simple but quite hard to track. I will answer for it myself. Maybe somebody will use this solution in the future.
LVL 2
mjoachiamiakAsked:
Who is Participating?
 
mjoachiamiakAuthor Commented:
The problem was that some of the libraries I used was compiled with /GL (global optimization) linker option which according to the http://msdn.microsoft.com/en-us/library/0zza0de8.aspx 
cannot be used together with /Z7, /Zi, /ZI  options.
In other words in debug version of my application I was trying to use release version of the library and it gave this strange buffer overrun error.

BR.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.