-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Description
- 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)
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.

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.
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)
Btw, fs.realpath.native works well.



