Skip to content
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

Channel between 64-bit and 32-bit process #304

Open
YaLTeR opened this issue Dec 8, 2022 · 0 comments
Open

Channel between 64-bit and 32-bit process #304

YaLTeR opened this issue Dec 8, 2022 · 0 comments

Comments

@YaLTeR
Copy link

YaLTeR commented Dec 8, 2022

Currently it doesn't work because message length is sent as a usize, which is 8 bytes in 64-bit processes and 4 bytes in 32-bit processes. This workaround seems to make it work for my specific case (limiting the total message length to the 32-bit process limit):

diff --git a/src/platform/unix/mod.rs b/src/platform/unix/mod.rs
index 41953ca..1384f2f 100644
--- a/src/platform/unix/mod.rs
+++ b/src/platform/unix/mod.rs
@@ -259,6 +259,8 @@ impl OsIpcSender {
         // which in a fragmented send will be smaller than the total message length.
         fn send_first_fragment(sender_fd: c_int, fds: &[c_int], data_buffer: &[u8], len: usize)
                                -> Result<(),UnixError> {
+            let len: u32 = len.try_into().unwrap();
+
             let result = unsafe {
                 let cmsg_length = mem::size_of_val(fds);
                 let (cmsg_buffer, cmsg_space) = if cmsg_length > 0 {
@@ -913,7 +915,7 @@ fn recv(fd: c_int, blocking_mode: BlockingMode)
     //
     // We use this to determine whether we already got the entire message,
     // or need to receive additional fragments -- and if so, how much.
-    let mut total_size = 0usize;
+    let mut total_size = 0u32;
     let mut main_data_buffer;
     unsafe {
         // Allocate a buffer without initialising the memory.
@@ -952,6 +954,8 @@ fn recv(fd: c_int, blocking_mode: BlockingMode)
         }
     }
 
+    let total_size: usize = total_size.try_into().unwrap();
+
     if total_size == main_data_buffer.len() {
         // Fast path: no fragments.
         return Ok((main_data_buffer, channels, shared_memory_regions))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant