ocaml-lsp icon indicating copy to clipboard operation
ocaml-lsp copied to clipboard

LSP crashes in a file with a long list (in VS Code and in Vim)

Open bhootd opened this issue 2 years ago • 4 comments

The attached video shows that LSP works well with a short list, but crashes while parsing a long list.

https://github.com/ocaml/ocaml-lsp/assets/1915507/9d1b9afd-2753-4c43-9af0-20a62b433955

bhootd avatar May 31 '23 15:05 bhootd

I can't reproduce the crash. Could you make sure that it happens on the latest version?

jfeser avatar Jun 29 '23 16:06 jfeser

I encountered the same issue on VScode. And I can reproduce the crash. When I browse a code file contains long array, for example https://github.com/semgrep/semgrep/blob/develop/src/data/Entropy_data.ml

ocaml-lsp-server crashed with following error:

[Error - 11:14:14] Server process exited with signal SIGBUS. [Info - 11:14:14] Connection to server got closed. Server will restart. true [Error - 11:14:14] Server process exited with signal SIGBUS. [Info - 11:14:14] Connection to server got closed. Server will restart. true [Error - 11:14:14] Server process exited with signal SIGBUS. [Info - 11:14:14] Connection to server got closed. Server will restart. true [Error - 11:14:15] Server process exited with signal SIGBUS. [Info - 11:14:15] Connection to server got closed. Server will restart. true [Error - 11:14:15] Server process exited with signal SIGBUS. [Error - 11:14:15] The OCaml Platform VS Code extension server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

======================== I'm not sure if it relate to merlin package.

vscode version 1.85.0 (Universal) OCaml Platform 1.14.1 opam switch: 4.14.0 ocaml-base-compiler.4.14.0 4.14.0

anthonygao avatar Dec 13 '23 03:12 anthonygao

Thanks for the link @anthonygao, I am also able to reproduce with this file. Opening it is enough to crash the server. I tried to run some queries with Merlin directly and did not notice.

In my log only two queries are made before the crash:

  • DocumentSymbol that relies on Merlin's outline command which I can call from the terminal without crashing.
  • CodeAction that is ocaml-lsp specific but calls multiple Merlin commands, I will try these.

voodoos avatar Dec 13 '23 14:12 voodoos

@rgrinberg I continued investigating and LSP crashes on the first call to Merlin dispatch. (I didn't go deeper yet.)

That's surprising since calling Merlin manually does not crash...

Edit: I went as far as the call to Typemod.merlin_type_structure in Mtyper which seems to be the place of the crash. The same test in Merlin runs perfectly fine, even with a much bigger array. I printed the parsetree feeded to merlin_type_structure and they are identical. But somehow, it crashes when performed by LSP.

voodoos avatar Dec 13 '23 15:12 voodoos