Skip to content

Infinite event loop after calling fs.realpath on 16-inch Macbook  #33936

@MMhunter

Description

@MMhunter
  • Version:
    10, 12 and Latest
  • Platform:
    MacOS 10.15.5 (16-inch, 2019)

What steps will reproduce the bug?

just call fs.realpath with /usr/bin/tclsh as first parameter.

require('fs').realpath('/usr/bin/tclsh', console.log)

image

Callback will not be executed, and the node process will be in an infinite event loop. (Not dead, but having high cpu usage).

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

Every time.

What is the expected behavior?

Callback should be executed as expected.

Additional information

Little inspecting into this issue:

The link path for /usr/bin/tclsh:

/usr/bin/tclsh -> usr/bin/tclsh8.5 -> /System/Library/Frameworks/Tcl.framework/Versions/8.5/tclsh8.5

In the fs.js, the realpath function attempts to use seenLinks to store symbolicLinks that have been already visited.
image

However, on MacOS 10.15.5, 16-inch MacOS, calling node's fs.lstat on /usr/bin/tclsh and usr/bin/tclsh8.5 share the same dev and ino number. This means that the seenLinks for id of usr/bin/tclsh8.5 will target to itself, then the infinite loop happens.

image

Another interesting thing, it looks like the fs.lstat won't get the same number with terminal command stat on this system. (But they are the same on older MacBook)

image

Btw, fs.realpath.native works well.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions