Incorrect programId
passed to Boogie causes memory leak in LSP server
#1863
Labels
area: performance
Performance issues
kind: bug
Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
part: language server
Support for LSP in Dafny (server part; client is in ide-vscode repo)
Boogie accepts a
programId
along with each program inExecutionEngine.InferAndVerify
. This ID is used as a key to partition a cache of recent parses:https://github.com/boogie-org/boogie/blob/ce03249fa06a7442df96352bb55e1bfba3e30365/Source/ExecutionEngine/ExecutionEngine.cs#L253-L257
A reasonable choice of key, for example, is the path of the current program. Alternatively, if there is only one program being verified, using
null
is also reasonable; in that case Boogie uses a default string (https://github.com/boogie-org/boogie/blob/ce03249fa06a7442df96352bb55e1bfba3e30365/Source/ExecutionEngine/ExecutionEngine.cs#L318-L321). This is what the Dafny CLI does:dafny/Source/DafnyDriver/DafnyDriver.cs
Line 263 in 38be532
dafny/Source/Dafny/DafnyMain.cs
Lines 236 to 239 in b6d7ae8
The legacy
DafnyServer
used by Emacs uses just a module name, because it can't operate on more than one file at a time, so the file name part isn't needed:dafny/Source/DafnyServer/DafnyHelper.cs
Line 85 in 495e7d2
The LSP server does something different:
dafny/Source/DafnyLanguageServer/Language/DafnyProgramVerifier.cs
Lines 103 to 107 in 5becffa
The test generator does the same thing, which is equally wrong, I think:
dafny/Source/DafnyTestGeneration/ProgramModification.cs
Lines 85 to 88 in b6d7ae8
In both cases one new program entry is created in the cache every time Boogie is queries. The cache's default expiration policy is a 10-minutes window, so for 10 minutes memory usage just grows.
The fix is to pass the program name instead of a freshly created unique string as the
programId
. I will open a PR soon.The text was updated successfully, but these errors were encountered: