Skip to main content
GameDev.net gamedev.net
🔒 Locked

[C++/DirectX] Strange Access Violation error...

Started by Gary the Llama Sep 9, 2008 at 10:16 AM 1 replies 1.7k views
Original Post
Gary the Llama
Gary the Llama
My main game loop randomly gives me this error message: Unhandled exception at 0x00000000 in Program.exe: 0xC0000005: Access violation reading location 0x00000000.

void GameLoop(HWND hWnd)
{
	__int64 currTime = 0;
	QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&currTime));

	float delta = (currTime - prevTime) * secsPerTick;
	float timePassed = currTime - prevTime;

	// GetInput();
	Update(delta, hWnd);
	Render(delta);

	prevTime = currTime;
}



This seems to be the offending line:

QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&currTime));



Aardvajk
Aardvajk
You're calling QPC correctly, so that is unlikely to be the offender.

The error you are getting is from something in your program trying to access memory you don't own, and I'd say given the address, you are trying to dereference a null pointer.

What gives you the impression that that line is the problem? Does the debugger seem to point there? I see nothing in your QPC line that could trigger a memory access exception.
Gary the Llama
Gary the Llama
Quote:
Original post by EasilyConfused
You're calling QPC correctly, so that is unlikely to be the offender.

The error you are getting is from something in your program trying to access memory you don't own, and I'd say given the address, you are trying to dereference a null pointer.

What gives you the impression that that line is the problem? Does the debugger seem to point there? I see nothing in your QPC line that could trigger a memory access exception.


When the exception occurs, it's stopped at that line of code. I noticed today that it only happens when I enable my collision detection code so it could be a problem there. I'm going to look further into the collision detection code and see what I can find.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.