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
Bug: Interface cast crashes on Windows 10 Builds < 20H2 #1464
Comments
Whether the cast succeeds depends on whether the object implements the requested interface. The Whether it crashes is also up to you - you can handle it more gracefully by avoiding the |
The code block above isn't our code. That's from the out/windows.rs file created by the windows-rs crate, hence the inability to avoid the .unwrap(). That's why I was saying this might also be invalid, because I know the code gen stuff changed in v0.29. |
Here's the full context, from the generated windows.rs file: pub fn BluetoothAddressType(&self) -> ::windows::Result<super::BluetoothAddressType> {
let this =
&::windows::Interface::cast::<IBluetoothLEAdvertisementReceivedEventArgs2>(self)
.unwrap();
unsafe {
let mut result__: <super::BluetoothAddressType as ::windows::Abi>::Abi =
::std::mem::zeroed();
(::windows::Interface::vtable(this).6)(::windows::Abi::abi(this), &mut result__)
.from_abi::<super::BluetoothAddressType>(result__)
}
} |
Ah! 😄 Yes, that has been fixed. You should already see the fix if you switch from the Notably, the Sorry for the confusion. |
Here's what that looks like in the pre-generated bindings: windows-rs/crates/libs/windows/src/Windows/Devices/Bluetooth/Advertisement/mod.rs Lines 1110 to 1117 in f06b0bb
|
Awesome, thanks! I'll go ahead and close this out then, and will get to testing against master while waiting for 0.31 ('cause I need #1438). Thanks for answering questions this late. :) |
windows::core::Interface::cast Cast can't be found |
You can find it in the ComInterface trait now. |
Which crate is this about?
windows
Crate version
0.28
Summary
First off: This is in 0.28, because I'm still waiting for some fixes in 0.31. If this is invalid for the new library, feel free to close and yell at me to upgrade. :)
We've been getting reports of .unwrap()'s panicking on Windows 10 builds older than 20H2 (which I realize are past lifetime, though we've got someone on an LTS complaining now too).
Specifically, this line in the generated code.
Expected behavior
Either no crashes for users on Windows 10 < 20H2, or else some sort of warning/error versus a full panic.
Actual behavior
Crashes on 20H2
Additional comments
No response
The text was updated successfully, but these errors were encountered: