Skip to content
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

Unimplement Clone for RenderDoc struct #25

Closed
ebkalderon opened this issue May 18, 2019 · 0 comments · Fixed by #29
Closed

Unimplement Clone for RenderDoc struct #25

ebkalderon opened this issue May 18, 2019 · 0 comments · Fixed by #29
Assignees
Labels

Comments

@ebkalderon
Copy link
Owner

After a bit of investigation, I have determined that it is not safe to implement Clone for RenderDoc under any circumstances. Allowing the entry point to be cloned is technically unsound because it can result in the following behavior:

  1. Clone existing RenderDoc instance foo into another variable binding bar.
  2. Send bar to a separate thread.
  3. bar.shutdown() is called early in the process to shut down the API, consuming self and preventing bar from being used further.
  4. However, the foo instance still exists. Calling any API methods (marked safe or unsafe) on it is undefined behavior.

Even so, while the shutdown() method is indeed prominently marked unsafe, there are other issues as well. The trigger capture and trigger multi-frame capture function calls are unsound if cloning the entry point is permitted because their corresponding stop and start methods could result in unpredictable behavior if called on multiple threads by separate RenderDoc instances on the same window and device handle pair.

Despite being a breaking API change, removing the Clone implementation is critical to statically preventing the memory and thread safety pitfalls described above. This should be documented clearly in the CHANGELOG.md so users looking to upgrade may be aware of the change.

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

Successfully merging a pull request may close this issue.

1 participant