From f4e67c1c6d62b945045ff74192b548f8b493cb56 Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Wed, 16 Oct 2024 02:49:50 +0000 Subject: [PATCH] Merge pull request #4679 from libraries/fix_inherited_fds fix(script): fixed panic when calling inherited_fds in root process --- script/src/scheduler.rs | 6 +++++- .../tests/ckb_latest/features_since_v2023.rs | 6 ++++++ script/testdata/spawn_cases | Bin 15664 -> 15728 bytes script/testdata/spawn_cases.c | 13 +++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/script/src/scheduler.rs b/script/src/scheduler.rs index 3c93c0ee82..358acda0e5 100644 --- a/script/src/scheduler.rs +++ b/script/src/scheduler.rs @@ -462,7 +462,11 @@ where ); } Message::InheritedFileDescriptor(vm_id, args) => { - let inherited_fd = self.inherited_fd[&vm_id].clone(); + let inherited_fd = if vm_id == ROOT_VM_ID { + Vec::new() + } else { + self.inherited_fd[&vm_id].clone() + }; let (_, machine) = self.ensure_get_instantiated(&vm_id)?; let FdArgs { buffer_addr, diff --git a/script/src/verify/tests/ckb_latest/features_since_v2023.rs b/script/src/verify/tests/ckb_latest/features_since_v2023.rs index e99dd32f5b..d5eb783ca0 100644 --- a/script/src/verify/tests/ckb_latest/features_since_v2023.rs +++ b/script/src/verify/tests/ckb_latest/features_since_v2023.rs @@ -1235,6 +1235,12 @@ fn check_spawn_index_out_of_bound() { assert_eq!(result.is_ok(), SCRIPT_VERSION == ScriptVersion::V2); } +#[test] +fn check_root_inherited_fds() { + let result = simple_spawn_test("testdata/spawn_cases", &[19]); + assert_eq!(result.is_ok(), SCRIPT_VERSION == ScriptVersion::V2); +} + #[test] fn check_spawn_cycles() { let script_version = SCRIPT_VERSION; diff --git a/script/testdata/spawn_cases b/script/testdata/spawn_cases index dbfddd345ed1167b7eaef2daf6f3c557fb28148e..c4acb37967aa7150eb5afaddb7a3994567c289f3 100755 GIT binary patch delta 2566 zcmZuze@qis9KSo-qd<|J1@)RrFyLIp*Hrl3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