Bug report: panic when EOF is not newline
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Bắt đầu tại lang/lsp/lsp_methods.go, khoảng dòng 314, nơi stack trace cho thấy panic out-of-range, và lần theo lệnh gọi từ lang/collect/collect.go ScannerFile. Tái hiện lỗi bằng lệnh abcoder parse đã được báo cáo và testdata/python/4_globvar, sử dụng một tệp không có dòng mới ở cuối. Được xem là hoàn tất khi cùng một đầu vào được phân tích mà không xảy ra panic.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
This is a low-priority bug.
Mitigation: add newline at EOF. This is the default behavior for most editors.
Try parsing the below causes panic.
(make sure no newline is at the end of file)
def foo():
return 2
panic logs:
$ go build && ./abcoder parse python testdata/python/4_globvar -o py.json --verbose && jq '.' py.json > p.py.json
[INFO]14:59:03 parse.go:139: open file '' and wait for 2 seconds for initialize workspace
[INFO]14:59:03 parse.go:81: start initialize LSP server zubanls...
[INFO]14:59:05 parse.go:95: end initialize LSP server
[INFO]14:59:05 spec.go:54: PythonSpec: using sysPaths [/home/zhenyang/anaconda3/envs/abcoder_zuban/lib/python3.11/site-packages /home/zhenyang/anaconda3/envs/abcoder_zuban/lib/python3.11/lib-dynload /home/zhenyang/anaconda3/envs/abcoder_zuban/lib/python311.zip /home/zhenyang/anaconda3/envs/abcoder_zuban/lib/python3.11 /home/zhenyang/.local/lib/python3.11/site-packages ]
[INFO]14:59:05 parse.go:183: start collecting symbols...
[ERROR]14:59:05 client.go:269: LSP server stderr: 2026-02-04T14:59:05.828171855+08:00 ERROR unhandled notification: Notification { method: "workspace/didChangeConfiguration", params: Object {"settings": Object {"pylsp": Object {"plugins": Object {"jedi_definition": Object {"follow_builtin_definitions": Bool(false)}}}}} }
[DEBUG]14:59:05 handler.go:96: handle method: textDocument/publishDiagnostics
[DEBUG]14:59:05 handler.go:98: param: {"diagnostics":[],"uri":"file:///home/zhenyang/O/data/Programs/bytedance/abcoder.remote/testdata/python/4_globvar/main.py"}
[DEBUG]14:59:05 handler.go:131: Received publishDiagnostics notification:
{"diagnostics":[],"uri":"file:///home/zhenyang/O/data/Programs/bytedance/abcoder.remote/testdata/python/4_globvar/main.py"}
[INFO]14:59:05 lsp_methods.go:311: Locate file: /home/zhenyang/O/data/Programs/bytedance/abcoder.remote/testdata/python/4_globvar/main.py, range: 0:0-2:0
panic: runtime error: index out of range [2] with length 2
goroutine 1 [running]:
github.com/cloudwego/abcoder/lang/lsp.(*LSPClient).Locate(0xc00013a6e0, {{0xc000578240, 0x60}, {{0x0, 0x0}, {0x2, 0x0}}})
/home/zhenyang/O/data/Programs/bytedance/abcoder.remote/lang/lsp/lsp_methods.go:314 +0x5a6
github.com/cloudwego/abcoder/lang/collect.(*Collector).ScannerFile.func1({0xc000578120, 0x59}, {0x1814030?, 0xc000559520?}, {0x0?, 0x0?})
/home/zhenyang/O/data/Programs/bytedance/abcoder.remote/lang/collect/collect.go:991 +0x506
path/filepath.walk({0xc000578120, 0x59}, {0x1814030, 0xc000559520}, 0xc0005534c8)
/usr/local/go/src/path/filepath/path.go:345 +0x105
path/filepath.walk({0xc00004c8a0, 0x51}, {0x1814030, 0xc000559450}, 0xc0005534c8)
/usr/local/go/src/path/filepath/path.go:369 +0x254
path/filepath.Walk({0xc00004c8a0, 0x51}, 0xc0005534c8)
/usr/local/go/src/path/filepath/path.go:427 +0x66
github.com/cloudwego/abcoder/lang/collect.(*Collector).ScannerFile(0xc00055c8c0, {0x1809a78, 0x23fc9e0})
/home/zhenyang/O/data/Programs/bytedance/abcoder.remote/lang/collect/collect.go:1008 +0x276
github.com/cloudwego/abcoder/lang/collect.(*Collector).Collect(0xc00055c8c0, {0x1809a78, 0x23fc9e0})
/home/zhenyang/O/data/Programs/bytedance/abcoder.remote/lang/collect/collect.go:174 +0x1ea
github.com/cloudwego/abcoder/lang.collectSymbol({0x1809a78, 0x23fc9e0}, 0x0?, {0xc00004c8a0?, 0x77359400?}, {{0x15e6795, 0x6}, 0x0, 0x0, 0x0, ...})
/home/zhenyang/O/data/Programs/bytedance/abcoder.remote/lang/parse.go:184 +0x12f
github.com/cloudwego/abcoder/lang.Parse({0x1809a78, 0x23fc9e0}, {0x7fff0de4b979?, 0x0?}, {{0x0, 0x0}, 0x1, {{0x15e6795, 0x6}, 0x0, ...}, ...})
/home/zhenyang/O/data/Programs/bytedance/abcoder.remote/lang/parse.go:98 +0x46f
main.newParseCmd.func2(0xc00039a200?, {0xc00037fb30, 0x2, 0x15e30a8?})
/home/zhenyang/O/data/Programs/bytedance/abcoder.remote/main.go:162 +0x376
github.com/spf13/cobra.(*Command).execute(0xc000134908, {0xc00037fae0, 0x5, 0x5})
/home/zhenyang/go/pkg/mod/github.com/spf13/[email protected]/command.go:985 +0xad4
github.com/spf13/cobra.(*Command).ExecuteC(0xc000134308)
/home/zhenyang/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x44f
github.com/spf13/cobra.(*Command).Execute(...)
/home/zhenyang/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
main.main()
/home/zhenyang/O/data/Programs/bytedance/abcoder.remote/main.go:57 +0x18
- Ngôn ngữ chính
- Go
- Star
- 391
- Fork
- 58
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 1
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 cloudwego/abcoder
-
Add native Codex hook support Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
-
Better error reporting Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
How to run the HTTP Mcp Server Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Tất cả issue của cloudwego/abcoder
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bazel-contrib/rules_go#4726 · 1 bình luận ·
-
area/auto-scaling area/monitoring area/ops-productivity kind/enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Type/Improvement
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
OpenNSW/nsw-srilanka#522 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100