-
Notifications
You must be signed in to change notification settings - Fork 132
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
SYSTEM_SENDBUF_SIZE is massively oversized on big-endian Linux systems #355
Comments
Forcing it to only ever use 32-bit values, like: diff --git a/src/platform/unix/mod.rs b/src/platform/unix/mod.rs
index ec3c712..bd24794 100644
--- a/src/platform/unix/mod.rs
+++ b/src/platform/unix/mod.rs
@@ -213,8 +213,8 @@ impl OsIpcSender {
/// Some of it is reserved by the kernel for bookkeeping.
fn get_system_sendbuf_size(&self) -> Result<usize, UnixError> {
unsafe {
- let mut socket_sendbuf_size: usize = 0;
- let mut socket_sendbuf_size_len = mem::size_of::<usize>() as socklen_t;
+ let mut socket_sendbuf_size: u32 = 0;
+ let mut socket_sendbuf_size_len = mem::size_of::<u32>() as socklen_t;
if getsockopt(
self.fd.0,
libc::SOL_SOCKET,
@@ -225,7 +225,7 @@ impl OsIpcSender {
{
return Err(UnixError::last());
}
- Ok(socket_sendbuf_size)
+ Ok(socket_sendbuf_size as usize)
}
}
allows ipc-channel to pass its whole test suite:
where before it just crashed:
I don't like this change, but I can't find a way to do the equivalent of a If this change would be acceptable I'd happily make a merge request with a DCO. But I'd rather do this properly. |
I think we need to read to byte array, then use https://doc.rust-lang.org/std/primitive.usize.html#method.from_be_bytes to read back using native byte order. |
Actually per https://pubs.opengroup.org/onlinepubs/007904975/functions/getsockopt.html this should be |
Ideally we would just rewrite it using https://github.com/rust-lang/socket2 |
This is defined by POSIX as an 'int'. Using a usize causes an invalid value to be read on 64-bit big endian platforms. Signed-off-by: A. Wilcox <[email protected]>
This is defined by POSIX as an 'int'. Using a usize causes an invalid value to be read on 64-bit big endian platforms. Signed-off-by: A. Wilcox <[email protected]>
Fixed in #357 |
I was attempting to try out Servo on a Power9 system, and was met with:
That didn't seem right, and running in the debugger I saw:
get_max_fragment_size()
callsSelf::first_fragment_size(*SYSTEM_SENDBUF_SIZE)
. which is lazily-initialised with the value ofget_system_sendbuf_size()
, which is implemented as:If I write the equivalent C out with some debugging printfs:
I get:
That 64-bit value is the same number we see in the crash. The shifted value of 229,376 looks correct from the output of
sysctl
:The text was updated successfully, but these errors were encountered: