Skip to content

Crash after destroying a couple of SwapchainKHR instances :/ #862

Closed Answered by Friz64
hcabel asked this question in Q&A
Discussion options

You must be logged in to vote

The values your builders point to are too short lived, resulting in a use after free. Extend the lifetime of these values by placing them in their own variable.

Fixed version (click to expand)
use std::{
    ffi::{CStr, CString},
    slice,
};

use ash::{extensions, vk};
use winit::{
    dpi::PhysicalSize,
    event::WindowEvent,
    event_loop::EventLoop,
    raw_window_handle::{HasWindowHandle, RawWindowHandle},
    window::WindowBuilder,
};

struct WindowSurface {
    pub loader: extensions::khr::Surface,
    pub handle: vk::SurfaceKHR,
}

pub struct DebugMessenger {
    messenger: vk::DebugUtilsMessengerEXT,
    loader: extensions::ext::DebugUtils,
}

pub fn main() {
    let event_lo…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
8 replies
@hcabel
Comment options

@hcabel
Comment options

@Friz64
Comment options

Answer selected by MarijnS95
@Friz64
Comment options

@hcabel
Comment options

@MarijnS95
Comment options

@hcabel
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants