fs.realpath infinite loop
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng việc tái hiện fs.realpathSync('d') trên Linux và so sánh với fs.realpathSync.native('d'), sử dụng cấu hình symlink được báo cáo và hành vi của strace làm hướng dẫn. Theo dõi entry point fs.realpathSync và đường dẫn phân giải symlink của nó. Được xem là hoàn tất khi lệnh trả về /home/niko/test/a/b/d thay vì lặp vô hạn, trong khi hành vi native vẫn chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- operating-systems
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 68/100