fs.realpath infinite loop
オープン
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
Version
v25.0.0
Platform
uname -a
Linux [hostname] 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
$ mkdir test
$ cd test
$ mkdir -p a/b/{c,d}
$ ln -s a/b/c # Make symlink to c dir in a/b
$ ln -s "c/../d" # Make symlink to d dir via c symlink
$ node -e "const fs = require('fs'); console.log(fs.realpathSync('d'));"
The node call never returns. If I call it with strace it's just checking the same file over and over:
...
statx(AT_FDCWD, "/home/niko/test/d", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFLNK|0777, stx_size=6, ...}) = 0
statx(AT_FDCWD, "/home/niko/test/d", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFLNK|0777, stx_size=6, ...}) = 0
...
How often does it reproduce? Is there a required condition?
Reproduces every time.
What is the expected behavior? Why is that the expected behavior?
Expected behavior is that the realpath would be printed to the console:
$ node -e "const fs = require('fs'); console.log(fs.realpathSync('d'));"
/home/niko/test/a/b/d
Note that realpathSync.native does work properly:
$ node -e "const fs = require('fs'); console.log(fs.realpathSync.native('d'));"
/home/niko/test/a/b/d
What do you see instead?
An infinite loop (see Steps section above).
Additional information
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Linux で fs.realpathSync('d') の再現から始め、報告されている symlink の設定と strace の挙動を手がかりに、fs.realpathSync.native('d') と比較してください。fs.realpathSync のエントリポイントと、symlink の解決経路を追跡してください。コマンドがループせずに /home/niko/test/a/b/d を返し、native の挙動が引き続き正しいことが完了の条件です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- operating-systems
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 活発
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 68/100