From 52ca88c81a9a207d3235a76253ecabd82cc5dee7 Mon Sep 17 00:00:00 2001 From: Mohanson Date: Thu, 14 Nov 2024 17:12:10 +0800 Subject: [PATCH] Append zero at the end of inherited_fds automatically (#126) --- contracts/Cargo.lock | 2 +- contracts/exec-callee/exec-callee-dbg/Cargo.lock | 2 +- contracts/spawn-caller-by-code-hash/src/entry.rs | 2 +- src/high_level.rs | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index 2ca3928..62c243a 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -228,7 +228,7 @@ dependencies = [ [[package]] name = "ckb-std" -version = "0.16.1" +version = "0.16.3" dependencies = [ "buddy-alloc", "cc", diff --git a/contracts/exec-callee/exec-callee-dbg/Cargo.lock b/contracts/exec-callee/exec-callee-dbg/Cargo.lock index 31765f8..4f9a5b0 100644 --- a/contracts/exec-callee/exec-callee-dbg/Cargo.lock +++ b/contracts/exec-callee/exec-callee-dbg/Cargo.lock @@ -219,7 +219,7 @@ dependencies = [ [[package]] name = "ckb-std" -version = "0.16.1" +version = "0.16.3" dependencies = [ "buddy-alloc", "cc", diff --git a/contracts/spawn-caller-by-code-hash/src/entry.rs b/contracts/spawn-caller-by-code-hash/src/entry.rs index b88114f..bc89398 100644 --- a/contracts/spawn-caller-by-code-hash/src/entry.rs +++ b/contracts/spawn-caller-by-code-hash/src/entry.rs @@ -12,7 +12,7 @@ pub fn main() -> Result<(), Error> { CStr::from_bytes_with_nul(b"world\0").unwrap(), ]; let mut std_fds: [u64; 2] = [0, 0]; - let mut son_fds: [u64; 3] = [0, 0, 0]; + let mut son_fds: [u64; 2] = [0, 0]; let (r0, w0) = syscalls::pipe()?; std_fds[0] = r0; son_fds[1] = w0; diff --git a/src/high_level.rs b/src/high_level.rs index de4f641..d716c86 100644 --- a/src/high_level.rs +++ b/src/high_level.rs @@ -700,6 +700,8 @@ pub fn spawn_cell( argv: &[&CStr], inherited_fds: &[u64], ) -> Result { + let mut inherited_fds = Vec::from(inherited_fds); + inherited_fds.push(0); #[cfg(not(feature = "native-simulator"))] { let index = look_for_dep_with_hash2(code_hash, hash_type)?; @@ -716,7 +718,7 @@ pub fn spawn_cell( Ok(process_id) } #[cfg(feature = "native-simulator")] - syscalls::spawn_cell(code_hash, hash_type, argv, inherited_fds) + syscalls::spawn_cell(code_hash, hash_type, argv, &inherited_fds) } /// Get inherited file descriptors.