Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Violation exception in WPF application and DirectX rasterizer

Tags:

c#

.net

wpf

directx

I have a WPF application that after some trivial playing around (opening and closing some application controls) is crashed. when I open the crash dump file I see that the exception is

FAULTING_IP: 
rgb9rast!D3D8RGBRast::CRGBContext::PackGenVertex+b4
000007fe`f7625b88 428b0c10        mov     ecx,dword ptr [rax+r10]

EXCEPTION_RECORD:  ffffffffffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 000007fef7625b88 (rgb9rast!D3D8RGBRast::CRGBContext::PackGenVertex+0x00000000000000b4)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 0000000000000000
Parameter[1]: 000000009f011620
Attempt to read from address 000000009f011620

which indicated access violation error in directx rasterization and the faulting thread stack trace is (I omitted call addresses)

rgb9rast!D3D8RGBRast::CRGBContext::PackGenVertex+0xb4
rgb9rast!D3D8RGBRast::CRGBContext::DoDrawOneGenIndexedPrimitive+0x72b
rgb9rast!D3D8RGBRast::CRGBContext::DP2DrawIndexedPrimitive2+0x1d4
rgb9rast!DX8SDDIFW::SDP2MFnParser::ParseDP2<DX8SDDIFW::CStdDrawPrimitives2<D3D8RGBRast::CRGBContext,D3D8RGBRast::CRGBStateSet,D3D8RGBRast::static_hash_map<unsigned long,D3D8RGBRast::CRGBStateSet,32,D3D8RGBRast::hash<unsigned long>,std::equal_to<unsigned long>,D3D8RGBRast::allocator<std::pair<unsigned long const ,D3D8RGBRast::CRGBStateSet> > >,DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt>,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt> & __ptr64,_D3DHAL_DP2COMMAND const * __ptr64,void const * __ptr64) __ptr64,89>,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(_D3DHAL_DP2COMMAND const * __ptr64,void * __ptr64) __ptr64,89> >::TMFnCaller,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt> & __ptr64,_D3DHAL_DP2COMMAND const * __ptr64,void const * __ptr64) __ptr64,89>,DX8SDDIFW::CConstDP2CmdIterator<D3D8RGBRast::SDP2NextCmdExt> >+0x69
rgb9rast!DX8SDDIFW::CStdDrawPrimitives2<D3D8RGBRast::CRGBContext,D3D8RGBRast::CRGBStateSet,D3D8RGBRast::static_hash_map<unsigned long,D3D8RGBRast::CRGBStateSet,32,D3D8RGBRast::hash<unsigned long>,std::equal_to<unsigned long>,D3D8RGBRast::allocator<std::pair<unsigned long const ,D3D8RGBRast::CRGBStateSet> > >,DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt>,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt> & __ptr64,_D3DHAL_DP2COMMAND const * __ptr64,void const * __ptr64) __ptr64,89>,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(_D3DHAL_DP2COMMAND const * __ptr64,void * __ptr64) __ptr64,89> >::DrawPrimitives2+0x345
rgb9rast!DX8SDDIFW::CSubDriver<D3D8RGBRast::CRGBDriver,D3D8RGBRast::CRGBContext,D3D8RGBRast::CRGBSurfAllocator,D3D8RGBRast::CRGBPerDDrawData,D3D8RGBRast::set<D3D8RGBRast::CRGBContext * __ptr64,std::less<D3D8RGBRast::CRGBContext * __ptr64>,D3D8RGBRast::allocator<D3D8RGBRast::CRGBContext * __ptr64> >,D3D8RGBRast::map<_DDRAWI_DIRECTDRAW_LCL * __ptr64,D3D8RGBRast::CRGBPerDDrawData,std::less<_DDRAWI_DIRECTDRAW_LCL * __ptr64>,D3D8RGBRast::allocator<std::pair<_DDRAWI_DIRECTDRAW_LCL * __ptr64 const,D3D8RGBRast::CRGBPerDDrawData> > >,D3D8RGBRast::set<D3D8RGBRast::IRGBSurface * __ptr64,std::less<D3D8RGBRast::IRGBSurface * __ptr64>,D3D8RGBRast::allocator<D3D8RGBRast::IRGBSurface * __ptr64> >,DX8SDDIFW::SFakeEntryPointHook<D3D8RGBRast::CRGBDriver> >::DrawPrimitives2+0x26
d3d9!SwDrawPrimitives2+0x7c
d3d9!CD3DDDIDX8::FlushStates+0x161
d3d9!CD3DBase::FlushStatesNoThrow+0x22
d3d9!CVertexBuffer::Lock+0xce
d3d9!CVertexBufferMT::Lock+0x7e
d3d9!CTLStream::Lock+0x6d
d3d9!CD3DDDIDX8::StartPrimTL+0x3b
d3d9!CD3DDDIDX8::ProcessIndexedPrimitiveC+0xa0
d3d9!CD3DBase::DrawIndexedPrimitive+0x489
wpfgfx_v0400!CD3DDeviceLevel1::DrawIndexedTriangleList+0x49
wpfgfx_v0400!CHw3DGeometryRenderer<unsigned long>::Render+0x152
wpfgfx_v0400!CHwShader::FixedFunctionDrawMesh3D+0x158
wpfgfx_v0400!CHwShader::DrawMesh3D+0x88
wpfgfx_v0400!CHwSurfaceRenderTarget::DrawMesh3D+0x1fb
wpfgfx_v0400!CHw3DSoftwareSurface::DrawMesh3D+0x38
wpfgfx_v0400!CSwRenderTargetSurface::DrawMesh3D+0x49
wpfgfx_v0400!CMetaRenderTarget::DrawMesh3D+0xee
wpfgfx_v0400!CModelRenderWalker::RealizeMaterialAndRender+0x17a
wpfgfx_v0400!CModelRenderWalker::ProcessMaterialAndRender+0x160
wpfgfx_v0400!CModelRenderWalker::RenderGeometryModel3D+0x11b
wpfgfx_v0400!CModelRenderWalker::PreSubgraph+0x19
wpfgfx_v0400!CModelIterator::Walk+0x64
wpfgfx_v0400!CModelRenderWalker::RenderModels+0x70
wpfgfx_v0400!CRender3DContext::PreSubgraph+0xd3
wpfgfx_v0400!CGraphIterator::Walk+0x4b
wpfgfx_v0400!CRender3DContext::Render+0xd9
wpfgfx_v0400!CDrawingContext::Render3D+0x277
wpfgfx_v0400!CMilViewport3DVisual::RenderContent+0x50
wpfgfx_v0400!CDrawingContext::PreSubgraph+0x766
wpfgfx_v0400!CGraphIterator::Walk+0x4b
wpfgfx_v0400!CDrawingContext::DrawVisualTree+0x23d
wpfgfx_v0400!CDrawingContext::Render+0x393
wpfgfx_v0400!CSlaveHWndRenderTarget::Render+0x206
wpfgfx_v0400!CRenderTargetManager::Render+0x4d
wpfgfx_v0400!CComposition::Render+0x28
wpfgfx_v0400!CComposition::ProcessComposition+0x13a
wpfgfx_v0400!CComposition::Compose+0x51
wpfgfx_v0400!CPartitionThread::RenderPartition+0x28
wpfgfx_v0400!CPartitionThread::Run+0x61
wpfgfx_v0400!CPartitionThread::ThreadMain+0x1c
kernel32!BaseThreadInitThunk+0xd
ntdll!RtlUserThreadStart+0x1d

this happens on only some PCs where I check the application. all have .Net 4.5 and Directx 11.
what can be the cause for that? when debugging / investigating the dump file I can't see any managed code that can lead to that.
the only hint I have is that I have some 3D content in the app, which can be related to some of the 3D rendering methods in the faulting thread stack trace.

like image 474
Oren Avatar asked Jul 21 '14 14:07

Oren


1 Answers

DirectX Rasterize (9 and above if I remember correctly) determine how the triangles are drawn. Given the three points of a triangle - you can draw them clockwise or anticlockwise, also you can determine if the surface of the triangles is facing inwards or outwards - that provides the intersection point.

It also provides the capability of setting Multisample and AntialiasedLine - those features (high process) allow the rendering of a much smoother lines. Remember that straight line don't really exists in a 2D screen - you might be familiar with the staircase effect in computer graphics or Jaggies.

Now when we use DirectX we are actually programming the GPU of the computer Graphic card. Therefor the graphic card must be DirectX ready - depends on the version off course.

Check your pc's hardware and determine whether the onbard or PCI graphics card are DirectX11 compliant.

Also you could adjust your WPF App rendering settings - tune it down if you will or switch it off all together at here

More info:

From the MSDN documentation:

Note ProcessRenderMode specifies a preference and does not necessarily change the actual rendering mode. Other parts of the system may override this preference and force the system into software rendering.

You can check the system DirectX info by using dxdiag in Window search box (Window 7 and above I think).

like image 165
Alex Leo Avatar answered Oct 13 '22 08:10

Alex Leo