Intermittent Access Violation ID2D1RenderTarget::E

2019-06-01 19:21发布

问题:

I have my Direct2D drawing loop which is running successfully for hours, even days, except for the intermittent access violation error. There is no pattern for this to happen, mostly after several hours, sometimes after just a few seconds.

Unhandled exception at 0x5f990099 (d3d11.dll) in XX.exe: 0xC0000005: Access violation reading location 0x00000fe0.

I am keeping a log of the return HRESULT of EndDraw if not successful. All the previous EndDraws seem to return S_OK. There aren't any other failed Direct2D API calls prior to this one.

ID2D1RenderTarget object is not NULL.

The Drawing loop is protected in a critical section.

Any ideas how to catch where this is coming from? Maybe the device or render target is entering some invalid state which I need to discover?