From f65abcbee7e60aa701a3c6c003b88653cc5c97fe Mon Sep 17 00:00:00 2001 From: jazelly Date: Wed, 4 Sep 2024 20:34:56 +0930 Subject: [PATCH] add some debug print to navigate segfault --- src/node_file.cc | 4 ++++ src/path.cc | 4 ++++ test/parallel/test-fs-cp.mjs | 12 ++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 621758cb57f8a7..20051235cf0f09 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -3136,6 +3136,8 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo& args) { auto src_path = std::filesystem::path(src.ToStringView()); #endif + std::cout << src.out() << std::endl; + BufferValue dest(isolate, args[1]); CHECK_NOT_NULL(*dest); ToNamespacedPath(env, &dest); @@ -3164,6 +3166,8 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo& args) { std::filesystem::file_type::not_found; bool src_is_dir = src_status.type() == std::filesystem::file_type::directory; + std::cout << dest.out() << std::endl; + if (!error_code) { // Check if src and dest are identical. if (std::filesystem::equivalent(src_path, dest_path)) { diff --git a/src/path.cc b/src/path.cc index fade21c8af9414..3cdf58bee8d550 100644 --- a/src/path.cc +++ b/src/path.cc @@ -274,6 +274,8 @@ void ToNamespacedPath(Environment* env, BufferValue* path) { return; } + std::cout << path->ToStringView() << std::endl; + // SAFETY: We know that resolved_path.size() > 2, therefore accessing [0], // [1], and [2] is safe. if (resolved_path[0] == '\\') { @@ -306,6 +308,8 @@ void ToNamespacedPath(Environment* env, BufferValue* path) { return; } + std::cout << "no way" << std::endl; + size_t new_length = resolved_path.size(); path->AllocateSufficientStorage(new_length + 1); path->SetLength(new_length); diff --git a/test/parallel/test-fs-cp.mjs b/test/parallel/test-fs-cp.mjs index 8827cda9379a7b..987da4430b2659 100644 --- a/test/parallel/test-fs-cp.mjs +++ b/test/parallel/test-fs-cp.mjs @@ -31,12 +31,12 @@ function nextdir() { // Synchronous implementation of copy. // It copies a nested folder containing UTF characters. -// { -// const src = './test/fixtures/copy/utf/新建文件'; -// const dest = nextdir(); -// cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true })); -// assertDirEquivalent(src, dest); -// } +{ + const src = './test/fixtures/copy/utf/新建文件'; + const dest = nextdir(); + cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true })); + assertDirEquivalent(src, dest); +} // It copies a nested folder structure with files and folders. {