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
Segmentation fault if destroy_shaders is true when calling create_program() #9
Comments
Thanks for the report. I will take a look |
Ok, I found the issue. So the way impl Drop for Shader {
fn drop(&mut self) {
unsafe {
bgfx_sys::bgfx_destroy_shader(self.handle);
}
}
} So in bgfx-rs the shader will always be dropped if it's not kept alive. So in this case setting |
I think the
(no semicolon on the last line, hence the ownership of the value is transferred to the caller) The lifetime of |
it's |
Oh, I see - That makes sense! |
Yeah, exactly. So I'm thinking that perhaps removing the last parameter for |
Right, that might make sense - Thanks a lot! |
If the last parameter (destroy_shaders) to
bgfx::create_program(&vsh, &fsh, false)
is set totrue
, I'm running into a segmentation fault; When set to false it is working correctly, but as far as I'm aware the shader objects are not needed anynore after the program is created.On Windows: "(exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)"
On Linux: "Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)"
The debugger seems to indicate the problem happens in
GL_CHECK(glUniform1iv(loc, num, data) );
on line 4427 in renderer_gl.cpp which is called frombgfx_rs::static_lib::frame()
.Sample repository: https://github.com/const-volatile/bgfx-imgui-glfw-rs-example
Toolchain: rustc 1.62.0-nightly (52ca603da 2022-04-12)
If changing line 60 here: https://github.com/const-volatile/bgfx-imgui-glfw-rs-example/blob/main/src/imgui_bgfx_renderer/mod.rs the segmentation fault can be observed.
Could this be an issue with bgfx-rs?
The text was updated successfully, but these errors were encountered: