segfaulting: DebugUtilsMessengerCallbackDataEXT::pMessageIdName may be null in debug callback (#1487)

* vulkano: DebugUtilsMessengerCallbackDataEXT::pMessageIdName may be null in debug callback

- https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkDebugUtilsMessengerCallbackDataEXT.html#VUID-VkDebugUtilsMessengerCallbackDataEXT-pMessageIdName-parameter

* make `Message::layer_prefix` an Option
This commit is contained in:
Philipp Renoth 2021-02-10 22:39:15 +01:00 committed by GitHub
parent ff1dd87a32
commit e66e9a1fa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,6 @@
# Unreleased
- **Breaking** `Message::layer_prefix` turned to Option to prevent segfaults when Vulkan message didn't provide `pMessageIdName` value
- **Breaking** On `AutoCommandBufferBuilder`, methods that bind a descriptor set now take a `dynamic_offsets` parameter
- **Breaking** On `AutoCommandBufferBuilder` and `SyncCommandBufferBuilder`, the `update_buffer` method now takes `data` by reference
- **Breaking** Made `PipelineLayoutDescTweaks` public, for use with compute pipelines

View File

@ -99,7 +99,10 @@ fn main() {
println!(
"{} {} {}: {}",
msg.layer_prefix, ty, severity, msg.description
msg.layer_prefix.unwrap_or("unknown"),
ty,
severity,
msg.description
);
})
.ok();

View File

@ -96,9 +96,12 @@ impl DebugCallback {
let user_callback = user_data as *mut Box<dyn Fn()> as *const _;
let user_callback: &Box<dyn Fn(&Message)> = &*user_callback;
let layer_prefix = CStr::from_ptr((*callback_data).pMessageIdName)
let layer_prefix = (*callback_data).pMessageIdName.as_ref().map(|msg_id_name| {
CStr::from_ptr(msg_id_name)
.to_str()
.expect("debug callback message not utf-8");
.expect("debug callback message not utf-8")
});
let description = CStr::from_ptr((*callback_data).pMessage)
.to_str()
.expect("debug callback message not utf-8");
@ -231,8 +234,8 @@ pub struct Message<'a> {
pub severity: MessageSeverity,
/// Type of message,
pub ty: MessageType,
/// Prefix of the layer that reported this message.
pub layer_prefix: &'a str,
/// Prefix of the layer that reported this message or `None` if unknown.
pub layer_prefix: Option<&'a str>,
/// Description of the message.
pub description: &'a str,
}