Application crashing at IDirect3DDevice9::Present when using DirectX Debug Runtime

Started by
9 comments, last by Norman0406 15 years, 9 months ago
Hello, I'm recently getting odd behaviour of my directx application. I used the DirectX Control Panel to switch to the debug runtime in order to get some additional information in the debug output window. But after that my application crashes at IDirect3DDevice9::Present, without giving information about the reason. In the debug output window it just says: First-chance exception at 0x6fcadfbf in Test - Console.exe: 0xC0000005: Access violation reading location 0x00000188. Unhandled exception at 0x6fcadfbf in Test - Console.exe: 0xC0000005: Access violation reading location 0x00000188. and that's it. I also checked for NULL pointers, but found none, the device has been created successfully. When switching back to the retail runtime it works, but then I'm not getting additional debug information any more. I also compiled with D3D_DEBUG_INFO, but still no error messages occur, just this "access violation". I use DirectX 9.0c and Visual Studio 2005. Does anyone have a clue? Norman.
Advertisement
You're going to have post some code around where it's crashing. Have you tried stepping through your program with the debugger? What do the variables around the crash site look like? Frankly, it's impossible for us to just guess what's going wrong. We need solid information.
Mike Popoloski | Journal | SlimDX
Alright, I did not post any code because there is nothing special about it, but here is the function where my app crashes:

void Render(){	g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,						 D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);	if (SUCCEEDED(g_pd3dDevice->BeginScene()))	{		Move(duration);		g_pConsole->Render();		Look();		g_pd3dDevice->EndScene();	}	g_pd3dDevice->Present(NULL, NULL, NULL, NULL);}

The Problem occurs when exectuing g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
The moment before, everything seems to be fine. g_pd3dDevice is not NULL and all the calls before returned S_OK. My Presentation parameters are created this way:

d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;d3dpp.BackBufferCount = 1;d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;d3dpp.BackBufferHeight = 600;d3dpp.BackBufferWidth = 800;d3dpp.EnableAutoDepthStencil = TRUE;d3dpp.FullScreen_RefreshRateInHz = 0;d3dpp.MultiSampleQuality = 0;d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;d3dpp.Windowed = TRUE;d3dpp.hDeviceWindow = g_hWnd;

Here is a more detailed extract of my debug output:
Direct3D9: :====> ENTER: DLLMAIN(6e9a9b10): Process Attach: 00000d14, tid=000015b4Direct3D9: :====> EXIT: DLLMAIN(6e9a9b10): Process Attach: 00000d14Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.'Test - Console.exe': Loaded 'C:\Windows\System32\nvd3dum.dll', No symbols loaded.Direct3D9: (INFO) :======================= Hal HWVP device selectedDirect3D9: (INFO) :HalDevice Driver Style bDirect3D9: :DoneExclusiveModeDirect3D9: (INFO) :Using FF to VS converterDirect3D9: (INFO) :Using FF to PS converterD3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.81098e-316f.  This is ok.Direct3D9: (WARN) :Ignoring redundant SetRenderState - 7Direct3D9: (WARN) :Ignoring redundant SetRenderState - 22Direct3D9: (WARN) :Ignoring redundant SetRenderState - 8D3DX: (INFO) Using SSE2 Instructions'Test - Console.exe': Loaded 'C:\Windows\System32\clbcatq.dll', No symbols loaded.First-chance exception at 0x6e9ddfbf in Test - Console.exe: 0xC0000005: Access violation reading location 0x00000188.Unhandled exception at 0x6e9ddfbf in Test - Console.exe: 0xC0000005: Access violation reading location 0x00000188.

The thing that confuses me is that everything works fine when I select the retail runtime...
What hardware and driver are you using? I've had PIX crash with the debug runtime on a Intel integrated chipset, but running perfectly well with the debug runtime with the same program on ATI and NVIDIA hardware, so I guess that drivers can cause a crash with the debug runtime.
Does it happen if you comment all rendering code (Move(), g_pConsole->Render(), and Look())? That is, if you're just calling Clear, BeginFrame, EndFrame, Present?

If it does, try commenting your code line-by-line until you find the line that causes it to crash.

If it crashes with an empty loop, it's most likely some driver bug.

Either way, make sure you've got the latest drivers for your card.
Sirob Yes.» - status: Work-O-Rama.
Just a guess, but I recently crashed on Present with no other indications. I traced it to a corrupted index buffer. The buffer got corrupted by overwriting it using incorrect loop variables for another array!

As suggested above:

- comment everything out and add calls back in one at a time till it crashes.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I checked it. Even when I comment out all relevant calls and just leaving initialization routine and primary rendering routine, so that there are no index buffers being created or other stuff, it still crashes. It now looks this way:
g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;d3dpp.BackBufferCount = 1;d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;d3dpp.BackBufferHeight = 600;d3dpp.BackBufferWidth = 800;d3dpp.EnableAutoDepthStencil = TRUE;d3dpp.FullScreen_RefreshRateInHz = 0;d3dpp.MultiSampleQuality = 0;d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;d3dpp.Windowed = TRUE;d3dpp.hDeviceWindow = g_hWnd;g_pD3D->CreateDevice(0, D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);

g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);// Begin the sceneif (SUCCEEDED(g_pd3dDevice->BeginScene())){	g_pd3dDevice->EndScene();}g_pd3dDevice->Present(NULL, NULL, NULL, NULL);

and it still does not work. Just setting d3dpp.Windowed = FALSE or switching back to the retail runtime makes it work. Yesterday I tried out 4 Versions of the SDK since 2004 and installed 3 different driver versions for my NVIDIA card, but it made no difference. Maybe a serious bug relevant only for a small group of users? Are there any ways to get detailed debug information using the retail runtime? I know that should not be possible, but maybe there is a way.
Is your application reaching EndScene()?
Yes it is. The call to BeginScene succeeds.
How about changing the stencil buffer format to D3DFMT_D16? Any help?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement