Skip to content

Memory limits for programs and the language server, import completion - #17

Merged
S42yt merged 1 commit into
masterfrom
fix/lsp-safety
Sep 30, 2026
Merged

S42yt merged 1 commit into
masterfrom
fix/lsp-safety

Conversation

@S42yt

@S42yt S42yt commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

This follows up on a report that the language server crashed in VS Code and then took the whole PC down. Nothing leads that far anymore: every path that can use too much memory now has a limit.

What I found

  • Checker: 26,743 mutated sources (truncated, token-inserted, spliced), each checked under a 1 GB limit, produced no hang, crash or memory blow-up. Synthetic shapes such as long ?? and ?. chains, deep nesting, long expressions and many globals all scale linearly.

  • Language server: I drove it like an editor over every example and stdlib file (typing character by character, with hover, completion, definition, symbols, formatting and code actions at random positions). It stays at 4–9 MB and answers every request.

  • Where the danger actually is:

    • a program that allocates without end, which had no limit at all;
    • the language server starting a heavy build through burnup;
    • a launcher that ends up starting itself.

    The last two are fixed in Never build from a language server start, lock installs, refuse shim links burnup#3 and Never start burn-analyzer from itself burn-analyzer#5.

Changes

  • Heap limit for programs: a program that keeps more than 3/4 of the computer's memory alive now stops with runtime error: out of memory … and a help line. Set BURN_MAX_HEAP_MB to change the limit, or 0 to turn it off. This works on bvm and in native executables. The GC also collects before the limit is crossed, not after the heap has doubled.

  • Language server cap: burn lsp caps its own address space at 4 GiB on Linux (BURN_LSP_MEMORY_MB, 0 turns it off). If anything ever goes wrong, only the server stops.

  • Import completion: completion inside import "..." and import ( ... ) offers standard modules, this project and its packages (including files inside a package) and local files, without offering the current file.

  • Ambiguous names: they no longer also report "cannot find".

  • VS Code (editors/vscode):

    • When burn.path isn't set, the extension uses burnup's ~/.burn/bin/burn if it exists.
    • It starts the server with ~/.burn/bin on PATH, in the workspace folder.

    VS Code started from the desktop often doesn't have ~/.burn/bin on its PATH, so it picked up an older burn without package support, which explains libraries not being recognized. The same change is in Find burnup's burn and put it on the language server's PATH vscode-burn#8.

  • Docs: the new variables are documented, and there's a Neovim/LazyVim section in the editors page.

Tests

  • New suite tests cover the heap limit (VM and native) and a real LSP session (ambiguity reported once, import completion). cargo test --release passes normally and with BVM_HOT=1, and clippy is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PCXUjgpGnka9y7AHKfnN3w


Generated by Claude Code

… complete import paths

Programs stop with an out of memory error when they keep more than 3/4 of the
computer's memory alive (BURN_MAX_HEAP_MB), on bvm and in native executables.
burn lsp caps its own address space at 4 GiB on Linux (BURN_LSP_MEMORY_MB).
The language server completes import paths: standard modules, the project's
packages and their files, and local files. An ambiguous name no longer also
reports that it cannot be found. The VS Code extension finds burnup's
~/.burn/bin/burn and gives the server a PATH that contains it.
@S42yt
S42yt merged commit 12d077f into master Sep 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant