Inverted didChange ranges can amplify document contents
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
- 49/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend-api-design, security
Direzione di ricerca
Start with the LSP range replacement path shared by watchdog and file-worker handling, then inspect the end-to-end harness lsp_textsync_e2e.py and its document setup and change flow. Reproduce the repeated inverted textDocument/didChange edit and request semantic tokens. Done means an end-to-end regression test confirms invalid edits do not grow the document or increase later request work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Inverted didChange ranges can amplify document contents
Summary
An inverted LSP textDocument/didChange range is applied without validating that start precedes end. Repeating a small edit with such a range expands the in-memory document and increases later language-feature work.
Steps to reproduce
Run lean --server, initialize it, and open a document containing eight lines of def x : Nat := 1. Send the following notification four times, incrementing the document version for each notification, then request textDocument/semanticTokens/full:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///tmp/Probe.lean","version":2},"contentChanges":[{"range":{"start":{"line":0,"character":1000000},"end":{"line":0,"character":0}},"text":""}]}}
Repeat as four separate notifications, increasing version each time.
The tested end-to-end harness is lsp_textsync_e2e.py; it performs framing, document setup, repeated edits, and token requests.
Expected behavior
The server should reject the inverted range or leave the document unchanged. Repeated invalid edits must not increase document size or the work required by later requests.
Actual behavior
On the reviewed 4.37.0-pre build, the semantic-token response grew from 40 integers at baseline to 80 after one edit and 640 after four edits. The worker remained alive in the tested cases. Relevant server range-edit code was unchanged between the reviewed commit and master a2a6b48ad40269ecf6a27e7790c7e611e7bb55d4.
Impact assessment
A client that can send changes for an open document can cause document and follow-on parsing work to grow from a small request. The demonstrated impact is CPU and memory resource exhaustion; the tested cases did not crash the worker.
Root cause
The range replacement path converts the supplied endpoints and performs text slicing without validating start <= end. Watchdog and file-worker handling share the affected range replacement behavior.
Suggested fix
Validate each range before slicing or replacing text. Reject inverted ranges and apply a consistent documented policy to positions beyond the document. Use overflow-safe checks for the resulting document size and enforce reasonable per-document and per-notification change limits before committing edits. Add an end-to-end regression test that repeats the inverted edit and verifies no document growth.
- 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