-
Notifications
You must be signed in to change notification settings - Fork 21
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
Undefined behaviour in library #9
Comments
More specifically the builder pattern disallows this via the borrow checker, but the Per Ash's README Fortunately we unified builders with their underlying struct and removed the |
Sorry for the late reply to your Issue! It looks like #10 will resolve the issue, so I'll check the PR there. And then I'm looking forward to the next ash release! |
Unfortunately, some of the PRs in #10 are not the correct fixes, so it doesn't look like we'll be able to merge them in anytime soon. I for one am looking forward to the release of the 0.38 series of ash. @stefnotch @MarijnS95 Thank you both for the pointers and clear explanations. |
This library uses Ash. One very tricky tidbit is that the current Ash builder pattern lends itself to accidentally causing undefined behaviour. This causes egui-winit-ash-integration to throw a validation error, followed by a rather impolite crash.
egui-winit-ash-integration/src/integration.rs
Lines 1185 to 1193 in 73c2e12
The issue here is that
.set_layouts(&[self.descriptor_set_layouts[0]])
causes an array to get created, and then a reference to it is passed to theset_layouts
function. Theset_layouts
function then takes a raw pointer to it, and casually assumes that the raw pointer will remain valid.The problem is that Rust drops the array right after the function is done. At this point, that raw pointer points at arbitrary memory.
Thus
dsc_alloc_info
ends up having an invalid pointer, which then causes a crash.Btw, I recently ran into that kind of issue in one of my projects. This issue is so common that Ash will change the builder pattern to something much safer in the next release.
The text was updated successfully, but these errors were encountered: