Skip to content

Bound LSP position-file reads against concurrent file growth #4750

Description

@Widthdom

Summary

The LSP position-line loader checks file size before reading but can still materialize more than the configured cap if the file grows concurrently.

Integrated v1.39.4 findings

  • LSP position-line loader can materialize a file that grows after the length check

Evidence

TryReadAllPositionLines checks FileStream.Length, calls StreamReader.ReadToEnd, and checks Position only afterward. A workspace file can grow beyond MaxPositionDocumentBytes during materialization.

Expected behavior / direction

Use a bounded streaming reader that stops before allocation crosses the cap, handles multibyte text safely, and returns a clear bounded diagnostic. Add a deterministic growth-during-read test.

Related closed issues

These issues remain closed; this is a new regression or follow-up observed on v1.39.4.

Environment

Reproduced with a locally built cdidx v1.39.4 from current origin/main at 87b8bf44210344f52ba4cb7827c149dfad32c0c8, using a fresh repository index on macOS arm64.

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .NET codebugSomething isn't workingsecurity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions