I'm struggling with a weird error which I can't figure out why it happens. So, once more, I ask for the aid of gamedev's wizards.
I'm using VisualStudio 2010 express edition and the game runs fine while in Debug configuration. When I run in Release configuration the game crashes upon the first access to a file (std::ifstream) giving an "access violation writing location" error message.
The error happens inside this function:
void __cdecl _lock_file (
FILE *pf
)
{
/*
* The way the FILE (pointed to by pf) is locked depends on whether
* it is part of _iob[] or not
*/
if ( (pf >= _iob) && (pf <= (&_iob[_IOB_ENTRIES-1])) )
{
/*
* FILE lies in _iob[] so the lock lies in _locktable[].
*/
_lock( _STREAM_LOCKS + (int)(pf - _iob) );
/* We set _IOLOCKED to indicate we locked the stream */
pf->_flag |= _IOLOCKED;
}
else
/*
* Not part of _iob[]. Therefore, *pf is a _FILEX and the
* lock field of the struct is an initialized critical
* section.
*/
EnterCriticalSection( &(((_FILEX *)pf)->lock) );
}
I've found out that in Debug the execution path takes the if, while in Release it takes else. My application does not create any additional thread.
My project configuration is the default "Empty Project" with the following changes:
Whole Program Optimization: No whole program optimization (By default it was using Link time code generation but this was giving me many linker error, so I turned it off)
Ignore Specific Library: msvcrt
SubsSystem: Windows
Does anyone have a clue of why this is happening?
Thanks in advance.