Re: file streams (ofstream, ifstream, fstream): access violation reading location 0x00000000
Thank you, Alex,
You can enable debugger to stop when exception is thrown, then examine
call stack. Go to Debug -> Exceptions... menu and enable debug stop for
0xC0000005 exception.
I did.
In Visual Studio .NET 2003, when I enabled it before starting the debugger,
exceptions began to happen fairly early and it was difficult to extract
anything from them (nothing obvious), and when I first started the debugger
and then enabled it for 0xC0000005, the only line that appeared in the call
stack was
00000000()
In Visual Studio 2005, first exceptions again appeared earlier than reported
without 0xC0000005 being enabled, but this time the top of the call stack
appeared to be the same in all cases:
00000000()
wxvault.dll!10007967()
[Frames below may be incorrect and/or missing, no symbols loaded for
wxvault.dll]
ntdll.dll!_RtlAllocateHeapSlowly@12() + 0x348 bytes
[my executable].exe!_unlock(int locknum=1170669791) Line 376 C
45c630ec()
(In certain cases, this constituted the entire call stack, and when calls
were made to create file streams, functions related to this appeared below
the above.)
The only code I could see (apart from disassembly) was this from the
'mlock.c' file
--------------------------------------------------------
void __cdecl _unlock (
int locknum
)
{
/*
* leave the critical section.
*/
LeaveCriticalSection( _locktable[locknum].lock );
}
--------------------------------------------------------
(with the arrow pointing to the closing curly brace).
Paul