-
Notifications
You must be signed in to change notification settings - Fork 187
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
non UTF8 encoded string in enumerate_instance_extension_properties function #830
Comments
this bug to my findings is only present in the extension VK_EXT_direct_mode_display |
Can you share the |
After checking the ICD on my ArchLinux machine with the following snippet: for p in entry.enumerate_instance_extension_properties(None).unwrap() {
let n = ::std::ffi::CStr::from_ptr(p.extension_name.as_ptr());
if n.to_string_lossy() == "VK_EXT_direct_mode_display" {
dbg!(p.extension_name);
}
} I get a sensible result out of the array:
Note that Ash initially allocates uninitialized memory for these structs, and it's up to the ICD to optionally zero out the whole string buffer after the first
Typically (as far as I'm aware) implementations should stop reading data after the first Are you sure that your test case isn't accidentally reading beyond the EDIT: For completeness #746 and its use of |
I should use the
The output of the code above:
This error is not present every run but I find it is pops out about half of the runs I do |
I will run its equivalent interfacing directly to the vulkan in C to see if I get a different behavior |
What do you want to "fix"? There's no weird behaviour here. The driver provides a valid UTF-8 string and a If you're testing on C, don't forget to set the array to uninitialized bytes first, to match |
It is a common operation to read and write NUL-terminated C string in the Vulkan API, yet the only helpers for that were thus far open-coded in the `Debug` printing implementations. Move them to separate functions that are exposed to the user, in hopes of helping them no longer misunderstand NUL-terminated strings (see e.g. #830). Important to note is that the array-copy for a static-sized `c_char` array has also been replaced with a `CStr` wrapper: this forces the user and our implementation to have a NUL-terminated string, but may now also panic if the incoming `CStr` with NUL-terminator is too large for the target `c_char` array.
It is a common operation to read and write NUL-terminated C string in the Vulkan API, yet the only helpers for that were thus far open-coded in the `Debug` printing implementations. Move them to separate functions that are exposed to the user, in hopes of helping them no longer misunderstand NUL-terminated strings (see e.g. #830). Important to note is that the array-copy for a static-sized `c_char` array has also been replaced with a `CStr` wrapper: this forces the user and our implementation to have a NUL-terminated string, but may now also panic if the incoming `CStr` with NUL-terminator is too large for the target `c_char` array. Finally, change the `::std` reference to `core::` to slowly help out with the `no_std` conversion.
It is a common operation to read and write NUL-terminated C string in the Vulkan API, yet the only helpers for that were thus far open-coded in the `Debug` printing implementations. Move them to separate functions that are exposed to the user, in hopes of helping them no longer misunderstand NUL-terminated strings (see e.g. #830). Important to note is that the array-copy for a static-sized `c_char` array has also been replaced with a `CStr` wrapper: this forces the user and our implementation to have a NUL-terminated string, but may now also panic if the incoming `CStr` with NUL-terminator is too large for the target `c_char` array.
It is a common operation to read and write NUL-terminated C string in the Vulkan API, yet the only helpers for that were thus far open-coded in the `Debug` printing implementations. Move them to separate functions that are exposed to the user, in hopes of helping them no longer misunderstand NUL-terminated strings (see e.g. #830). Important to note is that the array-copy for a static-sized `c_char` array has also been replaced with a `CStr` wrapper: this forces the user and our implementation to have a NUL-terminated string, but may now also panic if the incoming `CStr` with NUL-terminator is too large for the target `c_char` array.
It is a common operation to read and write NUL-terminated C string in the Vulkan API, yet the only helpers for that were thus far open-coded in the `Debug` printing implementations. Move them to separate functions that are exposed to the user, in hopes of helping them no longer misunderstand NUL-terminated strings (see e.g. #830). Important to note is that the array-copy for a static-sized `c_char` array has also been replaced with a `CStr` wrapper: this forces the user and our implementation to have a NUL-terminated string, but may now also panic if the incoming `CStr` with NUL-terminator is too large for the target `c_char` array.
It is a common operation to read and write NUL-terminated C string in the Vulkan API, yet the only helpers for that were thus far open-coded in the `Debug` printing implementations. Move them to separate functions that are exposed to the user, in hopes of helping them no longer misunderstand NUL-terminated strings (see e.g. #830). Important to note is that the array-copy for a static-sized `c_char` array has also been replaced with a `CStr` wrapper: this forces the user and our implementation to have a NUL-terminator at the end of the string, and the setter returns `Err()` when the given `CStr (with NUL-terminator) is too large for the static-sized array it has to be written to.
@GummyGun did you end up checking whether your driver only writes a single NUL-terminator, or does it zero the entire array minus the last item (by accident)?
On that note we've added |
…831) It is a common operation to read and write NUL-terminated C string in the Vulkan API, yet the only helpers for that were thus far open-coded in the `Debug` printing implementations. Move them to separate functions that are exposed to the user, in hopes of helping them no longer misunderstand NUL-terminated strings (see e.g. #830). Important to note is that the array-copy for a static-sized `c_char` array has also been replaced with a `CStr` wrapper: this forces the user and our implementation to have a NUL-terminator at the end of the string, and the setter returns `Err()` when the given `CStr (with NUL-terminator) is too large for the static-sized array it has to be written to.
There is a bug in the method enumerate_instance_extension_properties() where sometimes the last character in the field ExtensionProperties.extension_name is not properly encoded and may hold non-valid utf8 char.
The text was updated successfully, but these errors were encountered: