Again "Access Violation reading location 0x0000000"

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Mr.Gluck
Posts: 82
Joined: Tue Aug 31, 2004 8:02 pm

Again "Access Violation reading location 0x0000000"

Post by Mr.Gluck »

I have:

Code: Select all

main.cpp

#include "CMainMenu.h"
#include "include/irrlicht.h"
using namespace irr;

CMainMenu m_menu;

IrrlichtDevice *device =0;
IVideoDriver *driver = 0;
gui::IGUIEnvironment* guienv = 0;
IGUIElement* root = 0;

...

int main()
{
IrrlichtDevice *device =createDevice(EDT_NULL,dimension2d<s32>(640, 480), 16,false, false, false, 0); 
IVideoDriver* driver = device->getVideoDriver(); 

m_menu.readCFG();

...

CMainMenu.h

...
io::IXMLReader* xml = 0;
...
void CMainMenu::readCFG()
{
	xml = device->getFileSystem()->createXMLReader("config.xml");

bool mapParsing = true;
while(xml->read() && mapParsing == true) [b]! ON THIS LINE DEBUGGER STOPS[/b]
{
    if (core::stringw("Renderer") == xml->getNodeName()) 
        rendererString = xml->getAttributeValue(L"renderer");
...


CMainMenu.h
...
class CMainMenu 
{
public:
...
void readCFG();
...
dingo
Posts: 95
Joined: Tue Mar 09, 2004 5:02 am
Location: Brisbane, Australia
Contact:

Post by dingo »

What compiler and IDE are you using? (Helps us help you to debug - doesn't have to do with the problem)

Most likely what is happening is that you are passing a pointer to a function and that pointer is null (0x00000000). Then the function tries to do something on the data pointed to by the pointer but gets an error because the pointer is pointing at 0x0000000.

The solution is to step through your application and look at all the pointers passed to the function in which the Access Violation happens.

If using Visual Studio 2002 you would start a debug run with F10 then step through your small program by hitting F10 each line. Eventually you'll hit the line of code that creates the Violation. Remeber generally which area the line was in and place a breakpoint somewhere about it.

Then stop the debug run (click the stop button). Then start again with the F5 key (it will run until the break point). Then open the watch window and look for a variabe that is 0x0000000. That variable will be causing the problem. Then find out why that variable is 0x0000000.
-= Want your C code to control real life robots? www.users.on.net/~symes =-
dingo
Posts: 95
Joined: Tue Mar 09, 2004 5:02 am
Location: Brisbane, Australia
Contact:

Post by dingo »

My guess is that this is the problem line
xml = device->getFileSystem()->createXMLReader("config.xml");
Furthermore my guess is that your program cannot find the file "config.xml"

Just to debug try the entire path to the file, ie "C:/Irrlicht/Projects/SuperApp/config.xml" or whatever.

If using linux then try "/home/user/irrlicht/SuperApp/config.xml" or whatever and see if that fixes it
-= Want your C code to control real life robots? www.users.on.net/~symes =-
Mr.Gluck
Posts: 82
Joined: Tue Aug 31, 2004 8:02 pm

Post by Mr.Gluck »

I THINK that I know the line, where the x000000 appears. And this line I have marked at this post... its the xml->read() .

I said to compiler the path, but nothing,,, and i must say, that it works when it was in one file... than I made CMainMenu class and began to use readCFG function from it... the result is this strange problem for me.

OS: WinXP Pro SP2
IDE: VS. Net 2003

Debug information(i see 0x00000, BUT WHY?):

- xml 0x00000000 irr::io::IXMLReader *
- irr::IUnknown {ReferenceCounter=??? DebugName=??? } irr::IUnknown
- __vfptr CXX0030: Error: expression cannot be evaluated *
[0] CXX0030: Error: expression cannot be evaluated *
ReferenceCounter CXX0030: Error: expression cannot be evaluated int
- DebugName CXX0030: Error: expression cannot be evaluated const char *
CXX0030: Error: expression cannot be evaluated const char
Mr.Gluck
Posts: 82
Joined: Tue Aug 31, 2004 8:02 pm

Post by Mr.Gluck »

topic is closed...

i understood the problem... simply all main pointers were NULL. such as guienv, driver...
Post Reply