Extremely large UTF-16 columns can keep an LSP worker busy
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 56/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend-api-design, security
Direzione di ricerca
Start with Lean.Data.Lsp.Utf16.lspPosToUtf8Pos and the Position documentation, then trace the shared LSP conversion entry points. Add regression coverage for huge columns, supplementary-plane characters, and positions beyond line endings; verify conversion time stays bounded by line length and the out-of-range position follows the documented policy.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Extremely large UTF-16 columns can keep an LSP worker busy
Summary
An LSP position request with a character value far beyond the source line length can make position conversion perform work proportional to the supplied value. The same conversion is shared by hover and other language features.
Steps to reproduce
Run lean --server, complete the LSP initialize handshake, and open a document containing def x : Nat := 1\n. Then send this hover request as a standard LSP frame:
{"jsonrpc":"2.0","id":2,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///tmp/Probe.lean"},"position":{"line":0,"character":1e100000}}}
For comparison, repeat with "character":100000000.
Expected behavior
The server should clamp the out-of-range column to the line end, consistent with the documented position semantics, or reject it promptly under a documented policy. Conversion time should be bounded by the line length.
Actual behavior
On the reviewed 4.37.0-pre build, the exponent-form request produced no hover response within four seconds while the file worker remained alive; the 100000000 control request returned. The relevant UTF-16 conversion source remains unchanged on master a2a6b48ad40269ecf6a27e7790c7e611e7bb55d4. The open #15695 concerns long-line column computation performance; it does not add a bound based on the requested column or clamp this out-of-range input.
Impact assessment
A client with access to the LSP process can consume worker CPU and delay requests for the affected document. The demonstrated impact is denial of service, not a process crash or code execution.
Root cause
Lean.Data.Lsp.Utf16.lspPosToUtf8Pos passes the client-supplied UTF-16 character value into a conversion loop without first limiting it to the available length of the line. The Position documentation describes the intended clamping behavior, but the conversion path does not enforce it.
Suggested fix
Clamp the requested UTF-16 column to the selected line's available UTF-16 length before converting it to a UTF-8/source position. Ensure work is bounded by the line's actual length and use checked or saturating conversions for large JSON integers. Add regression tests for very large columns, supplementary-plane characters, and positions beyond line endings across shared LSP conversion entry points.
- Lingua principale
- Lean
- Stelle
- 10.3k
- Fork
- 1.1k
- Merge medio
- 19h 8m
- PR unite (30g)
- 421
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16681 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
leanprover/lean4#16305 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
leanprover/lean4#16299 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16257 ·
I maintainer di solito rispondono entro 1 giorno
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
leanprover/lean4#15683 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
jxxghp/MoviePilot#7576 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
chenhg5/cc-connect#2340 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
Fei2411/DeepSeek-Bot#2148 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
danielmiessler/LifeOS#2939 ·
I maintainer di solito rispondono entro 4 giorni