PSReadLine crashes with ArgumentOutOfRangeException on SetCursorPosition when quickly editing long input line (top=29, BufferHeight=29)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Tái hiện sự cố với BufferHeight 29, sau đó lần theo lệnh gọi SetCursorPosition được báo cáo qua MoveCursorToEnd trong quá trình làm mới bộ đệm console. Đảm bảo vị trí phía trên của con trỏ luôn nằm trong khoảng 0..BufferHeight-1 và xác minh rằng việc chỉnh sửa nhanh bằng Backspace rồi nhập tiếp không còn đóng phiên nữa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues, especially the pinned issues.
Exception report
# PSReadLine crashes with ArgumentOutOfRangeException on rapid Backspace editing
## Environment
- PowerShell: 7.x (console)
- PSReadLine version: 2.4.5
- Terminal: Windows Console host, BufferHeight = 29
## Bug description
Typing commands and rapidly pressing Backspace caused PSReadLine to crash with
`ArgumentOutOfRangeException` thrown from `SetCursorPosition`:
Exception:
System.Management.Automation.PSArgumentOutOfRangeException:
Cannot process argument transformation on parameter 'top'.
Parameter name: 'top' cannot be greater than '29'
## Reproduction steps
1. Open a PowerShell console with a short window (BufferHeight ~29).
2. Type `vine update`, then `vine inventory`.
3. Press Backspace ~13 times quickly to erase, retype `vine inventory`, press Enter.
4. Press `r` — crash occurs.
## Root cause analysis
- The reported cursor line index is `29`, which is out of the valid range `0..28`
when BufferHeight == 29.
- The crash happened during input-line redraw after a burst of Backspace keys,
suggesting PSReadLine's cursor position calculation went out of bounds
(off-by-one at the bottom edge of the buffer).
## Notes
- This is not caused by the command itself — any command can trigger it when
the buffer is short and Backspace is pressed rapidly.
- Suggested fix: clamp the cursor `top` coordinate to `[0, BufferHeight-1]`
before calling `SetCursorPosition`.
## Reporter context
Found while testing **Vine** (https://codeberg.org/Milktown/vine), a
text-instruction-based package manager for Windows. It has nothing to do with
the crash, just FYI — Vine is a neat open-source project worth a look. :)
Screenshot
Environment data
PS Version: 7.6.3
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.4.5
PSReadLine EditMode: Windows
OS: 10.0.19038.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 29
Steps to reproduce
Steps to reproduce
- Open PowerShell with a window sized so console BufferHeight is exactly 29 (e.g. 80 columns x 29 rows)
- Run: vine update
- Run: vine inventory
- Press Backspace 13 times rapidly (no text may remain, or partial)
- Retype: vine inventory
- Press Enter
- Type a single character, e.g. r — crash happens on redraw
Expected behavior
Expected behavior
- Cursor line is clamped to valid range (0..BufferHeight-1); typing any character redraws the input line without errors
Actual behavior
Actual behavior
- PSReadLine throws ArgumentOutOfRangeException: top parameter (29) is out of valid range 0..28
- Stack: SetCursorPosition <- MoveCursorToEnd <- ... console buffer refresh; entire session crashes and closes
- Ngôn ngữ chính
- C#
- Star
- 4.4k
- Fork
- 341
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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.
Issue khác của PowerShell/PSReadLine
-
Needs-Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
PowerShell/PSReadLine#5205 ·
-
Needs-Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
PowerShell/PSReadLine#5121 ·
-
Needs-Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
PowerShell/PSReadLine#5045 ·
-
Area-CommandHelp Issue-Enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
PowerShell/PSReadLine#3470 · 3 reaction ·
-
Needs-Triage :mag:
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
PowerShell/PSReadLine#5214 ·
Tất cả issue của PowerShell/PSReadLine
Issue tương tự
-
[Feat] 조합 영역 구분선 개선 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
type/automation type/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
t/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
ci-failure-cause test-failure
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100