-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 assert failed left: 4096 right: 0
- when sending > 4096 bytes in windows pipe message mode
#6460
Comments
This seems to be unrelated to the actual buffer size. If the sent message is more than 4096 at all, this happens. Perhaps this is related to #5307 |
panic assert failed left: 4096 right: 0
- when sending > 4096 bytes in windows pipe message mode
Debug assertion that fails: https://github.com/tokio-rs/mio/blob/15050b9a24ffb528e97c61aa789aa338093d6059/src/sys/windows/named_pipe.rs#L881 For some reason we read I don't have a Windows machine to debug this, but it would be nice to know what the error is. Maybe it's an error we can actually ignore? @MolotovCherry can you run with a fork of Mio where the error is logged? |
I've not looked into it but this documentation seems related:
|
@Thomasdezeeuw The problem is probably what ChrisDenton said, but yes I can run with a fork of Mio where it's logged and report back with the result. How do I do this? Edit: ^^ Nevermind. Running the original example in release mode and logging the reply of Though when implementing this in a full |
@MolotovCherry can you try tokio-rs/mio#1772 ? You can set the following in your project's dependencies:
|
I seem to be unable to test this out due to the different versions (1.0 vs 0.8.11). So tokio isn't taking the new dependency Edit: I cloned it and patched the version manually. You indeed did fix the problem. I now have access to both!
|
Can just add pub unsafe fn read_overlapped(
&self,
buf: &mut [u8],
overlapped: *mut OVERLAPPED,
) -> io::Result<Option<usize>> {
let len = std::cmp::min(buf.len(), u32::MAX as usize) as u32;
let res = ReadFile(
self.handle.raw(),
buf.as_mut_ptr() as *mut _,
len,
std::ptr::null_mut(),
overlapped,
);
if res == 0 {
let err = io::Error::last_os_error();
if err.raw_os_error() != Some(ERROR_IO_PENDING as i32) {
return Err(err);
}
}
let mut bytes = 0;
let res = GetOverlappedResult(self.handle.raw(), overlapped, &mut bytes, 0);
if res == 0 {
let err = io::Error::last_os_error();
if err.raw_os_error() == Some(ERROR_IO_INCOMPLETE as i32) || err.raw_os_error() == Some(ERROR_MORE_DATA as i32) {
Ok(None)
} else {
Err(err)
}
} else {
Ok(Some(bytes as usize))
}
} |
@forxfoo I think tokio-rs/mio#1772 will solve the problem. It's still an open question on how to deal with datagram pipes though. |
I used this pr before, but still encountered some problems.
so I looked at the code and made the simple fixes as above. i sorry, i use |
Version
1.37.0
Platform
Edition Windows 11 Pro
Version 23H2
Installed on 10/5/2022
OS build 22631.3296
Experience Windows Feature Experience Pack 1000.22687.1000.0
Description
Sending a message in the pipe larger than 4096 causes an assertion panic.
Output
Granted I'm not well versed in using pipes yet, so perhaps clients should only be send messages of max size MAX_BUF, but on the other hand, it's super easy for a client to crash the server this way
Edit: It's only a debug assert, won't crash in production
The text was updated successfully, but these errors were encountered: