Skip to content

Commit

Permalink
add some debug print to navigate segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
jazelly committed Sep 4, 2024
1 parent 5c76aaf commit f65abcb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3136,6 +3136,8 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& 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);
Expand Down Expand Up @@ -3164,6 +3166,8 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& 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)) {
Expand Down
4 changes: 4 additions & 0 deletions src/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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] == '\\') {
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions test/parallel/test-fs-cp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
{
Expand Down

0 comments on commit f65abcb

Please sign in to comment.