Closed kwobny closed 1 year ago
After further experimentation, I think this bug happens when luminance_glfw::GlfwSurface is dropped before luminance::shader::Program is dropped.
This code results in a seg fault.
let program;
let mut surface;
let surface_result: Result<GlfwSurface, GlfwSurfaceError<()>> = GlfwSurface::new(|glfw| {
glfw.create_window(300, 300, "hello world", WindowMode::Windowed)
.ok_or(GlfwSurfaceError::InitError(InitError::Internal))
});
surface = surface_result.unwrap();
program = Box::new(
surface.context
.new_shader_program::<VertexSemantics, (), ()>()
.from_strings(VS_STR, None, None, FS_STR)
.unwrap()
.ignore_warnings()
);
But the same code with the top two variable declarations swapped does not fault.
// surface and program variable declarations swapped
let mut surface;
let program;
let surface_result: Result<GlfwSurface, GlfwSurfaceError<()>> = GlfwSurface::new(|glfw| {
glfw.create_window(300, 300, "hello world", WindowMode::Windowed)
.ok_or(GlfwSurfaceError::InitError(InitError::Internal))
});
surface = surface_result.unwrap();
program = Box::new(
surface.context
.new_shader_program::<VertexSemantics, (), ()>()
.from_strings(VS_STR, None, None, FS_STR)
.unwrap()
.ignore_warnings()
);
Yes, it’s a drop issue, and is a well known problem. I’m probably going to prioritize that in the next release.
Duplicate of #304.
Hi, I encountered a segmentation fault while working on a personal project. The fault occurs whenever I close the window that my program creates. I'm using Linux with X11 and OpenGL as my luminance backend. Here are the crates and versions I am using (retrieved from Cargo.lock): luminance: 0.47.0 luminance-front: 0.6.1 luminance-gl: 0.19.1 luminance-glfw: 0.18.2 luminance-derive: 0.10.0 luminance-std140: 0.2.1 glfw: 0.44.0 gl: 0.14.0
Here is the backtrace I got from GDB.
The backtrace suggests that the fault occurs when a shader program struct is dropped.
Upon further examination, it seems the bug occurs when the shader program struct is dropped in a scope that it is not declared in. Take this code for example:
The above code results in a seg fault. But the same code without the extra scope does not:
A seg fault also occurs if I place the code in another function and call it from main:
The examples above are partially derived from the Learn Luminance book: https://phaazon.github.io/learn-luminance/chapter_2_3.html The files
vs.glsl
andfs.glsl
are from the book as well, but I have also put them below. vs.glsl:fs.glsl: