Access violation reading location 0, due to source file path ?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am wondering if you have some tips on how I can debug a very strange problem?
I have C++ application which crashes or runs fine depending on the path of one of its source files.
I can work around it by using the "good" path, but it still leaves me with the question of what on earth is going on here?



Working scenario

I add a plain C-file to my project: ..TXUButtonTW.c
Compile 32-bit exe w/debug symbols, and everything works fine.

(the C-file simply contains some struct and array definitions).

Crash scenario
If I include the same file from a different directory then this breaks the .exe somehow:

I remove said ..TXUButtonTW.c ..
.. and then I add the same file but from a different directory: ..SharedBMPFilesButtonTW.c
Compiling 32-bit exe w/debug succeeds.

However, execution now runs into a null pointer exception even before entering my Main-function (called "MainTask"):

First-chance exception at 0x0107B6F2 in app.exe: 0xC0000005: Access violation reading location 0x00000000.


Heres the stack trace:

app.exe!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 37 C++
app.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 26 C++
app.exe!__tmainCRTStartup() Line 237 C
app.exe!WinMainCRTStartup() Line 164 C
kernel32.dll!76df33aa() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!774d9ef2() Unknown
ntdll.dll!774d9ec5() Unknown

View the full article
 
Back
Top