-
Notifications
You must be signed in to change notification settings - Fork 515
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
Panic on access to MIB_TCPTABLE2 access when built against nightly (only) #2842
Comments
The slice of |
@Nerixyz Firstly, thanks for the very quick response and explanation.
Interesting. While I didn't write the relevant code in zbus, I did notice that it's based on example C code from the official win32 docs.
Not sure I understand. 🤔 The |
Yea, in C, Note that |
Hmm.. are you saying that while the struct doesn't represent this in any way, there are actually multiple entries there, so I can just |
I guess so, cause this seems to help: diff --git a/zbus/src/win32.rs b/zbus/src/win32.rs
index 24e1236d..f75e31e1 100644
--- a/zbus/src/win32.rs
+++ b/zbus/src/win32.rs
@@ -214,7 +214,7 @@ pub fn socket_addr_get_pid(addr: &SocketAddr) -> Result<u32, Error> {
let tcp_table = tcp_table.as_mut_ptr().cast::<MIB_TCPTABLE2>();
let num_entries = unsafe { (*tcp_table).dwNumEntries };
for i in 0..num_entries {
- let entry = unsafe { (*tcp_table).table.get_unchecked(i as usize) };
+ let entry = unsafe { *(*tcp_table).table.as_ptr().add(i as usize) };
let port = (entry.dwLocalPort & 0xFFFF) as u16;
let port = u16::from_be(port); If I'm right, please feel free to close this issue. Thanks for your help in either case. |
@Nerixyz Thanks again. I'm close this now. It would be great if the documentation could be helpful here but I'm guessing that's difficult with generated docs and a huge API surface. |
Summary
I'm seeing a strange issue where the code that's been working for a while, started to panic but only if built with nightly and not with stable Rust.
Crate manifest
Crate code
The text was updated successfully, but these errors were encountered: