Skip to content

Fix crash in DX11 unmap if map was called before frame capture #3601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from

Conversation

Sanakan8472
Copy link

The problem can be reproduced by calling map of a DX11 buffer and then keeping that open until a frame is captured in which unmap is called. The call to

bool found = FindDiffRange(MapWrittenData, record->GetShadowPtr(ctxMapID, 1), len, s, e);

would crash as record->GetShadowPtr(ctxMapID, 1) returns nullptr and FindDiffRange does not guard against this.

The problem can be reproduced by calling map of a DX11 buffer and then keeping that open until a frame is captured in which unmap is called.
The call to
```cpp
bool found = FindDiffRange(MapWrittenData, record->GetShadowPtr(ctxMapID, 1), len, s, e);
```
would crash as `record->GetShadowPtr(ctxMapID, 1)` returns nullptr and `FindDiffRange` does not guard against this.
@baldurk
Copy link
Owner

baldurk commented May 2, 2025

This change does not seem like the right fix and it should be handled differently - in general unmapping a buffer on DX11 during a frame capture that was not mapped during that frame should be detected and should cause the entire frame capture to fail and have to retry the next frame.

Can you please open a bug report for this and include a reproducible test case so that this can be investigated?

@Sanakan8472
Copy link
Author

This change does not seem like the right fix and it should be handled differently - in general unmapping a buffer on DX11 during a frame capture that was not mapped during that frame should be detected and should cause the entire frame capture to fail and have to retry the next frame.

Can you please open a bug report for this and include a reproducible test case so that this can be investigated?

Thanks for the quick response @baldurk!
Sure, I can open a bug. I've hit this bug when trying to capture https://github.com/ezEngine/ezEngine, so the repo case is a bit big. Is that fine or should I try to create a minimal test case? Might take a while though.

As a bit of context, the project I'm working on has a bunch of mapped temp buffers that multiple background threads can copy into. This prevents the need for thread synchronization when accessing ID3D11DeviceContext. So if I understand you correctly, while this is in spec from what I can tell, RenderDoc can't support this use case, so I might be better off finding a different solution to my threading problem, independent of fixing the Renderdoc crash?

@baldurk
Copy link
Owner

baldurk commented May 2, 2025

RenderDoc can't handle mapping a buffer prior to capturing and then unmapping it during capture because the map needs to be intercepted on D3D11, but the overhead of intercepting all maps is too high. If this is encountered RenderDoc will fail to capture the desired frame and instead retry on the next frame (up to 5 times).

As long as I can reproduce the problem it doesn't have to be minimally sized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants