Sitelet https://github.com/nodejs/node/issues/56049
Skip to content

fs.rmSync('速') crash without throw #56049

Description

@kanasimi

Version

23.3.0

Platform

Windows 10

Subsystem

No response

What steps will reproduce the bug?

When fs.rmSync('速') files with name containing “速”, node 23.3.0 will crash without throw.

How often does it reproduce? Is there a required condition?

Everytime

What is the expected behavior? Why is that the expected behavior?

Delete the file normally.

What do you see instead?

The program just crashed.

Additional information

There are other special characters that can cause similar problems, such as “請”. This problem did not occur in previous versions.

Activity

  1. added
    fsIssues and PRs related to file-system APIs and the fs module.
    on Nov 28, 2024
  2. islandryu commented on Nov 29, 2024

    @islandryu
    Member

    It might be related to #55773.

  3. kanasimi commented on Nov 29, 2024

    @kanasimi
    Author

    v22.11.0 is OK, but v23.0.0 also has problems.

  4. joyeecheung commented on Nov 29, 2024

    @joyeecheung
    Member

    This seems, once again, a problem from using std::filesystem::path on Windows, and wasn't taken care of as part of #55015 (cc @anonrig who authored #53617). See #53063 (comment) on an explanation about this class of bugs.

    (With the amount of crashes reported for this bug on Windows, I start to feel that we might as well should just forbid std::filesystem::path in the code base unless it's absolutely justified, as it's so easy to miss the encoding inconsistency on Windows.....)

  5. anonrig commented on Nov 29, 2024

    @anonrig
    Member

    I recommend forbidding std::filesystem::path as well. It's not worth it.

  6. added
    windowsIssues and PRs related to the Windows platform.
    on Nov 30, 2024
  7. added
    confirmed-bugIssues and PRs for confirmed bugs.
    good first issueIssues that are suitable for first-time contributors.
    on Dec 2, 2024
  8. joyeecheung commented on Dec 2, 2024

    @joyeecheung
    Member

    It seems no one is working on it yet, so marking it as good first issue. See #53063 (comment) on how this sort of bug happens and how they can be fixed. In this case I believe one just needs to change

    node/src/node_file.cc

    Lines 1629 to 1630 in 56e5bd8

    env, permission::PermissionScope::kFileSystemWrite, path.ToStringView());
    auto file_path = std::filesystem::path(path.ToStringView());

    To use ToU8StringView() instead, since the call was actually changed to use std::filesystem calls, which only takes std::filesystem::paths.

  9. geeksilva97 commented on Dec 2, 2024

    @geeksilva97
    Contributor

    I will give it a try

  10. Yeaseen commented on Dec 3, 2024

    @Yeaseen
    Contributor

    @geeksilva97 I would like to try this if you haven't done it yet. I started building with the suggested change and will write the test to check. This would be my first contribution here. Thank you.

  11. geeksilva97 commented on Dec 3, 2024

    @geeksilva97
    Contributor

    @geeksilva97 I would like to try this if you haven't done it yet. I started building with the suggested change and will write the test to check. This would be my first contribution here. Thank you.

    Of course. Go for it.

  12. kanasimi commented on Dec 3, 2024

    @kanasimi
    Author

    Do we need to do an extensive check to see if there are other places with similar problems?

  13. jimmywarting commented on Dec 12, 2024

    @jimmywarting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.fsIssues and PRs related to file-system APIs and the fs module.good first issueIssues that are suitable for first-time contributors.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions