Access violation reading location 0x00000000 ошибка

I’m having a very strange issue with a space invaders game I’m working on. Basically I get an access violation error:

Unhandled exception at 0x5edad442 (msvcr100d.dll) in
SpaceInvaders.exe: 0xC0000005: Access violation reading location
0x00000000.

when I include the piece of code below. visual studio takes me to «strcmp.asm» when debugging. Note that Im not using strcmp() in any of my code. Is there anything wrong with the code, or is this a problem beyond the scope of what I’ve included? Thanks for any help

const char* invarray[] = {"invader0.png", "invader1.png", "invader2.png", "invader3.png", "invader4.png"}; 
int i=0;
//Creates 55 invaders
for (int y=0; y<250; y+=50){
    for (int x=0; x<550;x+=50){
        Invader inv(invarray[y/50], x+50, y+550, 15, 15, 1, false, 250);
        invaders[i] = inv;
    }
}

Invader constructor:

Invader::Invader(const char *pic, int x, int y, int w, int h, bool dir, bool des, int point) : MovingObject(pic, x, y, w, h) , direction(dir), destroyed(des), b(0), points(point){};

MovingObject Constructor

MovingObject::MovingObject(const char *pic, int x, int y, int w, int h):picture(pic), positionX(x), positionY(y), width(w), height(h) {};

  • Remove From My Forums
  • Question

  • I tried to run in debug mode some c++ code but i have a message box which appear with:

    Unhandled exception at 0x00411bc6 in Trial 3d1.exe: 0xC0000005: Access violation reading location 0x00000000.

    Can someone explain me the meaning of this message and how i can resolve my problem.

    I am using visual studio express 2005 and directX(december2006).

Answers

  • This means you are trying to read from a variable initialised to NULL or set to NULL through a failed allocation or call to QueryInterface. You should debug your application in a debugger, maybe VC itself, and check where it is going wrong.

  • You can read from pointers that have NULL values. What you can’t do is use them to point at something.

    char *string_Pointer1 = NULL;

    char *string_Pointer2 = NULL;   

    if (string_Pointer1 == NULL) {     // OK, reads string_Pointer1 but not what it points at

       string_Pointer1 = «hello»;        // OK, sets string_Pointer1 to point at the string

    }

    *string_Pointer2 = ‘x’;     // BOOM! Access violation reading location 0x00000000.

Crash reason: EXCEPTION_ACCESS_VIOLATION (3221225477), Error reading location 0x00000000 Что с этим делать ?

Здравствуйте у меня возникли проблемы с CRACHем в игре и чтобы я не делал игра вылетает. Печально может кто знает что делать с этим ? Red Engine Crash Log
—————————————
Build: Not Set [ Compiled May 20 2015 ]

Crash reason: EXCEPTION_ACCESS_VIOLATION (3221225477), Error reading location 0x00000000

Crashed Thread:

Thread ID: 4444

callstack:
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x220319 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x2202b7 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x21fcce — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x220e44 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x2273cb — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x8be20f — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x744eb5 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x752e47 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x7518f9 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x74ed61 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x755933 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x76bdb5 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x769f37 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x69a794 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xcde3a — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x69a5a4 — <Unknown File>(0)
Scaleform::Render::Matrix2x4<float>::prepend() + 0x111356 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xaeb41 — <Unknown File>(0)
Scaleform::Render::Matrix2x4<float>::prepend() + 0x10be2a — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xaee47 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xa66 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0x21cfd — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xcc9 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xdbc — <Unknown File>(0)
Scaleform::Render::Matrix2x4<float>::prepend() + 0x269498 — <Unknown File>(0)
BaseThreadInitThunk() + 0xd — <Unknown File>(0)
RtlUserThreadStart() + 0x21 — <Unknown File>(0)

Debug Information
================================================================

Commandline: «G:GamessteamappscommonsteamappscommonThe Witcher 3binx64witcher3.exe»

Thread ID: 3028

callstack:
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xb159a2 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xb15561 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xb15470 — <Unknown File>(0)
Scaleform::Render::Matrix4x4<float>::SetIdentity() + 0xb27bb0 — <Unknown File>(0)
Scaleform::Render::Matrix2x4<float>::prepend() + 0x271437 — <Unknown File>(0)
Scaleform::Render::Matrix2x4<float>::prepend() + 0x2715de — <Unknown File>(0)
BaseThreadInitThunk() + 0xd — <Unknown File>(0)
RtlUserThreadStart() + 0x21 — <Unknown File>(0)

и так далее на систему и железо вроде грешить не стоит
Processor: AMD FX(tm)-8350 Eight-Core Processor (8 CPUs), ~4.0GHz
Memory: 16384MB RAM
Available OS Memory: 16366MB RAM
Page File: 4234MB used, 28495MB available
DirectX Version: DirectX 11
DX Setup Parameters: Not found Card name: NVIDIA GeForce GTX 660 Ti
Manufacturer: NVIDIA
Chip type: GeForce GTX 660 Ti
DAC type: Integrated RAMDAC
Device Key: EnumPCIVEN_10DE&DEV_1183&SUBSYS_35631458&REV_A1
Display Memory: 4095 MB
Dedicated Memory: 3009 MB
Shared Memory: 1086 MB
Current Mode: 1680 x 1050 (32 bit) (60Hz)

Короче вообще беда .

Last edited: May 24, 2015

Проблема была в жестком диске, игра находилась на виртуальном диске который был создан из-за ограничения виндовс на максимальный размер тома в 2 терабайта после, переноса игры в область основной памяти ошибка исчезла.

Last edited: May 26, 2015

Hi,

I am using below code in my application.

This works fine in 64-bit application, but when i am trying to use in 32-bit application i am receiving «Unhandled exception at 0x00000000 in acad.exe: 0xC0000005: Access violation reading location 0x00000000.», in 

acdbOpenObject(pBlockDef, objBlock, AcDb::kForRead);

Can anyone help me in solving this issue.

*****************************************************Code Used*************************************************************

BOOL insertBlock(CString csBlockName, CString csLayerName, ads_point ptIns, double dScale, double dHeight, double dRotation, CString csTextStyle, AcDbObjectId& objInsert, BOOL bIsMSpace)

{

AcDbObjectId objBlock;
if (ensureSymbolAvailability(csBlockName, objBlock) == FALSE) { return FALSE; }

// Convert the insertion base point
AcGePoint3d geBasePoint(ptIns[X], ptIns[Y], ptIns[Z]);

// Create a new block reference object
AcDbBlockReference *pInsert = new AcDbBlockReference;
pInsert->setBlockTableRecord(objBlock);
pInsert->setPosition(geBasePoint);
pInsert->setNormal(AcGeVector3d(0, 0, 1));
pInsert->setRotation(dRotation);
pInsert->setScaleFactors(AcGeScale3d(dScale, dScale, dScale));
pInsert->setLayer(csLayerName);

// Add this entity to the current drawing
// NOTE: This will create the block reference without any attributes in it
objInsert = appendEntityToDatabase(pInsert, bIsMSpace);

// Open the block definition for read
AcDbBlockTableRecord *pBlockDef; acdbOpenObject(pBlockDef, objBlock, AcDb::kForRead);

AcDbBlockTableRecordIterator *pIterator; pBlockDef->newIterator(pIterator);

AcDbEntity *pEnt;
AcDbAttributeDefinition *pAttdef;

// For each entity in the block
for (pIterator->start(); !pIterator->done(); pIterator->step())
{

}

}

*********************************************************************************************************************************

Thanks,

Chockalingam

Access violation reading location 0x00000000.

Topic is solved

standtall007

Knows some wx things
Knows some wx things
Posts: 31
Joined: Sat Jan 30, 2016 1:30 am

Access violation reading location 0x00000000.

Hi all, i have a problem loading models into my game engine which i use wxWidgets for the GUI.
The problem is that whenever i use my Import function it will crash when i have 2+ panels opened which both of them uses/contains a canvas consisting of wxGLCanvas.
the weird thing is that i can load models in either of them (either the first window OR the second, not both!) but then i try to open a model into the other and it instantly crash… it point me to a location in textmeasure.cpp which should be used by wxWidgets, and i will leave the important code here for you guys to see if there is something i have overlooked…

Code: Select all

wxWindow *current_page = m_auinotebook1->GetCurrentPage();
	int current_page_index = m_auinotebook1->GetPageIndex(current_page);
	wxString current_label = m_auinotebook1->GetPageText(current_page_index);
	
	wxFileDialog OpenDialog(
		this, _("Choose a file to open"), wxEmptyString, wxEmptyString, _("Fbx files (*.fbx)|*.fbx|Collada files (*.dae)|*.dae|Obj files (*.obj)|*.obj|Quake 2 models (*.md2)|*.md2|Doom 3 models (*.md5mesh)|*.md5mesh"), wxFD_OPEN, wxDefaultPosition);
	
	// Creates a "open file" dialog with 4 file types
	if (OpenDialog.ShowModal() == wxID_OK) // if the user click "Open" instead of "Cancel"
	{
		if (canvas3Ds.size() > 0)
		{
			for (std::vector<Viewport3D *>::iterator iter = canvas3Ds.begin(); iter != canvas3Ds.end(); iter++)
			{
				if (current_label == (*iter)->getTitle())
				{
					//Model loading code inserted here!
				}
			}
		}
		OpenDialog.Close();
	}

the getTitle() function is basically a function that works the same way as GetLabel() for the Viewport3D.

Thanks,
David.

User avatar

doublemax

Moderator
Moderator
Posts: 18315
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Access violation reading location 0x00000000.

Post

by doublemax » Sat Jun 25, 2016 7:53 pm

Except for missing sanity checks for the return values of GetCurrentPage() and GetCurrentPageIndex() there is nothing relevant in that code.

Run the code under a debugger and get the exact location where it crashes and a call stack / backtrace.

Use the source, Luke!

standtall007

Knows some wx things
Knows some wx things
Posts: 31
Joined: Sat Jan 30, 2016 1:30 am

Re: Access violation reading location 0x00000000.

Post

by standtall007 » Sat Jun 25, 2016 8:42 pm

doublemax wrote:Except for missing sanity checks for the return values of GetCurrentPage() and GetCurrentPageIndex() there is nothing relevant in that code.

Run the code under a debugger and get the exact location where it crashes and a call stack / backtrace.

Hi doublemax, i did what you told me to regarding the debugging, and it appears it crashes at line: 167 in evtloop.cpp.

the line has this code:

i don’t know, i just tried with using F11 instead of F10 and now it says it needs a file called delete_scalar_size.cpp
and i don’t know if wxWidgets is supposed to have such file but it isn’t in my wxWidgets-master folder!

but the last error says it is at line 1546 in string.h (wxWidgets kind of string of course :) )

and the code at that line has this:

Code: Select all

return wxPrivate::wxStringAsBufHelper<T>::Get(*this, len);

i am currently using the newest version of wxWidgets (upgraded yesterday!)

standtall007

Knows some wx things
Knows some wx things
Posts: 31
Joined: Sat Jan 30, 2016 1:30 am

Re: Access violation reading location 0x00000000.

Post

by standtall007 » Sat Jun 25, 2016 8:47 pm

Alright doublemax, i have finally figured out the source of the problem…

it is when i load a model into one of the scenes, and when i try to load the same model directly into the other scene then it crashes because i think that OpenDialog returns the same string value on scene 2 as scene 1! but how to fix it, i don’t know.

User avatar

doublemax

Moderator
Moderator
Posts: 18315
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Access violation reading location 0x00000000.

Post

by doublemax » Sat Jun 25, 2016 9:18 pm

it is when i load a model into one of the scenes, and when i try to load the same model directly into the other scene then it crashes because i think that OpenDialog returns the same string value on scene 2 as scene 1!

I don’t see any code that reads the path from the wxFileDialog, so i don’t know what your code is doing there.

If a crash happens somewhere inside the wxWidgets code, the interesting part of the call stack are the last lines in *your* code that lead to the crash.

Use the source, Luke!

standtall007

Knows some wx things
Knows some wx things
Posts: 31
Joined: Sat Jan 30, 2016 1:30 am

Re: Access violation reading location 0x00000000.

Post

by standtall007 » Sat Jun 25, 2016 9:56 pm

doublemax wrote:

it is when i load a model into one of the scenes, and when i try to load the same model directly into the other scene then it crashes because i think that OpenDialog returns the same string value on scene 2 as scene 1!

I don’t see any code that reads the path from the wxFileDialog, so i don’t know what your code is doing there.

If a crash happens somewhere inside the wxWidgets code, the interesting part of the call stack are the last lines in *your* code that lead to the crash.

Thanks doublemax i’ll check it out when i can get to the pc again!

i just got this on the pc in Visual studio 2015:

> Editor.exe!wxTextMeasure::DoGetTextExtent(const wxString & string, int * width, int * height, int * descent, int * externalLeading) Line 127 C++

this is the last line of the callstack

User avatar

doublemax

Moderator
Moderator
Posts: 18315
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Access violation reading location 0x00000000.

Post

by doublemax » Sat Jun 25, 2016 11:08 pm

> Editor.exe!wxTextMeasure::DoGetTextExtent(const wxString & string, int * width, int * height, int * descent, int * externalLeading) Line 127 C++

this is the last line of the callstack

Like i said, the interesting part is the last line in your code that got executed. Because there you must pass some invalid data into a wxWidgets method.

Use the source, Luke!

standtall007

Knows some wx things
Knows some wx things
Posts: 31
Joined: Sat Jan 30, 2016 1:30 am

Re: Access violation reading location 0x00000000.

Post

by standtall007 » Sat Jun 25, 2016 11:33 pm

doublemax wrote:

> Editor.exe!wxTextMeasure::DoGetTextExtent(const wxString & string, int * width, int * height, int * descent, int * externalLeading) Line 127 C++

this is the last line of the callstack

Like i said, the interesting part is the last line in your code that got executed. Because there you must pass some invalid data into a wxWidgets method.

Ohh, sorry for my stupidity :) i am not fully woken yet :P i will try and investigate it further ;-) Thanks for your help once again doublemax.

standtall007

Knows some wx things
Knows some wx things
Posts: 31
Joined: Sat Jan 30, 2016 1:30 am

Re: Access violation reading location 0x00000000.

Post

by standtall007 » Tue Jun 28, 2016 3:14 am

Hi doublemax, i want to thank you for pointing out the use of the call stacks!
I have finally fixed it, and it turned out to be much more complicated than i originally thought it would be.
First of, the ONLY thing that actually the problem had to do with wxWidgets was the if statement inside the iterator loop.
And it wasn’t telling me much but it turned out to be because of the closure of the viewports that flawed on me.

Понравилась статья? Поделить с друзьями:

Не пропустите эти материалы по теме:

  • Яндекс еда ошибка привязки карты
  • Access ошибка 3343
  • Access sql ошибка синтаксиса при определении поля
  • Access denied почему такая ошибка
  • Access ошибка 3326

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии