Skip to content

Mock provider panics on a position in the phantom last line of newline-terminated documents #63

Closed

Description

@e54-bot

Audit finding H2 — verified live.

Problem

puzzle/text.rs:49-75 — line_starts appends a phantom empty line after a trailing \n; line_byte_range then strips \r\n/\n from that already-empty line, producing an inverted start > end range, and line_text slices it -> panic (exit 101).

Reachable via any positioned method: lpp/definition, lpp/references, lpp/rename, lpp/validateEdits. {line: last, character: 0} is a valid position per spec 6.4.

Reproduction

printf '%s\n' \
 '{"jsonrpc":"2.0","id":1,"method":"lpp/initialize","params":{"protocolVersion":"1.0"}}' \
 '{"jsonrpc":"2.0","id":2,"method":"lpp/validateEdits","params":{"document":{"uri":"file:///a.xdl","languageId":"x-demo-lang","version":1,"text":"puzzle p {\n  target = 1\n  start = 0\n  ops {\n    a: x => x + 1\n  }\n  solution = [ a ]\n}\n"},"edits":[{"range":{"start":{"line":8,"character":0},"end":{"line":8,"character":0}},"newText":"//"}]}}' \
 | ./target/release/lpp-mock-provider   # panics: byte range starts at 87 but ends at 86

Acceptance criteria

  • Positions on the phantom last line return invalidPosition or a normal result; never a panic.
  • Same for CRLF-terminated documents.
  • Regression test + green suite.

Activity

  1. added
    bugSomething isn't working
    ready-for-implementationContract settled; an Engineer can implement without inventing a decision
    on Oct 15, 2026
  2. e54-bot commented on Oct 15, 2026

    @e54-bot
    ContributorAuthor

    Fixed in #86 (commit 15015bc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready-for-implementationContract settled; an Engineer can implement without inventing a decision

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions