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

Premature gabrage collection of DebugReportCallback delegate #44

Open
SinnersSumit opened this issue Apr 7, 2018 · 1 comment
Open

Comments

@SinnersSumit
Copy link

I've found a rather odd bug in which the delegate used for DebugReportCallback is garbage collected, thus causing a random crash when the native handler calls it during the next vulkan call.
Fortunately, I believe this should be easily fixed by simply adding the delegate as a member to DebugReportCallback
My temporary solution was to simply preserve the delegate by keeping a reference to it bound to my window. It works well enough.

@FacticiusVir
Copy link
Owner

You'll see in the samples that your workaround is the approach I've taken so far - hold a reference to the delegate in the calling code because the unmanaged function pointer passed to Vulkan isn't tracked by the garbage collector. Adding a reference to the DebugReportCallback handle adds some complexity to the generator, as it'll need to have a concept of reference lifetimes to understand which passed-in references are now owned by the returned/created handle, and I need to check where else in the API are callbacks being used this way.

I'll likely add this as part of the rework I'm doing for Vulkan 1.1 - I'm going to have to add more scope for manual overrides to the generator, and I expect this change will fit in there.

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

No branches or pull requests

2 participants