intersystems / language-server

Repository for the VS Code Language Server
https://marketplace.visualstudio.com/items?itemName=intersystems.language-server
Other
16 stars 6 forks source link

Extension crashing in WSL #329

Open daimor opened 1 month ago

daimor commented 1 month ago

What it's going on, how to make it working? IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2022.1.1 (Build 374U) Tue Oct 18 2022 17:51:36 EDT Switched on trace, but nothing useful there image

Looks like it happening not for every class, only one particular

[Error - 2:39:06 PM] The InterSystems Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

[Error - 2:39:06 PM] Client InterSystems Language Server: connection to server is erroring.
write EPIPE
[Error - 2:39:06 PM] Server process exited with code 1.
[Info  - 2:39:06 PM] Connection to server got closed. Server will restart.
true
[Trace - 2:39:06 PM] Sending request 'initialize - (0)'.

........

[Error - 2:39:06 PM] Client InterSystems Language Server: connection to server is erroring.
write EPIPE
/root/.vscode-server/extensions/intersystems.language-server-2.5.0/server/out/server.js:2
[Error - 2:39:06 PM] The InterSystems Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
daimor commented 1 month ago

And why issue with just one file, affects the whole extension. If it caught something that it can't process just die, and does not work anymore, until reload

daimor commented 1 month ago

Managed to get minimal reproducible class, the issue in © in description

/// ©
Class User.crash
{

}
isc-bsaviano commented 1 month ago

Hi @daimor, if you roll back to version 2.4.4 does the issue persist? I couldn't reproduce this on my Mac or PC, but I don't have WSL set up.

daimor commented 1 month ago

Installed 2.4.4, no difference also crashed

daimor commented 1 month ago

Looks like it's happening on any unicode symbol anywhere in the code

daimor commented 1 month ago
[Trace - 11:49:46 AM] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///root/Projects/CAM/test.mac",
        "languageId": "objectscript",
        "version": 1,
        "text": "ROUTINE test \ntest ;\n    #; тест"
    }
}

[Trace - 11:49:46 AM] Sending request 'textDocument/codeAction - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///root/Projects/CAM/test.mac"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}

[Trace - 11:49:46 AM] Sending request 'textDocument/documentSymbol - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///root/Projects/CAM/test.mac"
    }
}

[Trace - 11:49:46 AM] Sending request 'textDocument/semanticTokens/full - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///root/Projects/CAM/test.mac"
    }
}

[Trace - 11:49:46 AM] Sending request 'textDocument/diagnostic - (4)'.
Params: {
    "textDocument": {
        "uri": "file:///root/Projects/CAM/test.mac"
    }
}

[Trace - 11:49:46 AM] Sending request 'textDocument/documentLink - (5)'.
Params: {
    "textDocument": {
        "uri": "file:///root/Projects/CAM/test.mac"
    }
}

/root/.vscode-server/extensions/intersystems.language-server-2.5.0/server/out/server.js:2
[Info  - 11:49:46 AM] Connection to server got closed. Server will restart.
true
[Trace - 11:49:46 AM] Sending request 'initialize - (0)'.
daimor commented 1 month ago
isclexer = require('./isclexer.node');

moniker = "INT";

console.log(isclexer.Tokenize(' ; test',moniker));
console.log(isclexer.Tokenize(' ; тест',moniker));
$  bug node bug.js
[ [ { l: 1, s: 7, p: 1, c: 6 } ] ]
/root/Projects/bug/bug.js:6
console.log(isclexer.Tokenize(' ; тест',moniker));
                     ^

Error: std::bad_alloc
    at Object.<anonymous> (/root/Projects/bug/bug.js:6:22)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.13.1
$ uname -a
Linux TAB120657 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
isc-bsaviano commented 1 month ago

@daimor Something similar was reported in #298. Could changing locales fix your issue? If not and VS Code pulled the right extension version (should be the linux-x64 version based on your output) I can try to reproduce this.

daimor commented 1 month ago

locale is UTF8, no idea which locale to change, I used russian language as an example, I see no reason that it should crash on whatever locale is set anyway I discovered it for sign © which is not language specific the codebase I'm working on should be in English only anyway

isc-bsaviano commented 1 month ago

@daimor I upgraded my WSL2 distribution to 22.04 and node to 20 and then tried to reproduce this issue but I couldn't. Here's my terminal output. I used the current version of linux-x64-isclexer.node found in GitHub.

Welcome to Node.js v20.13.1.
Type ".help" for more information.
> const i = require("./linux-x64-isclexer.node")
undefined
> i.Tokenize(" ; text","INT")
[ [ { l: 1, s: 7, p: 1, c: 6 } ] ]
> i.Tokenize(" ; тест","INT")
[ [ { l: 1, s: 7, p: 1, c: 6 } ] ]
> .exit
bsaviano@USSSTbsaviano:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy
bsaviano@USSSTbsaviano:~$ uname -a
Linux USSSTbsaviano 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
daimor commented 1 month ago

Reproduced in docker

docker run -v .:/demo -w /demo node:20 bug.js

image

isc-bsaviano commented 1 month ago

Is that container running in Docker on WSL or Docker Desktop on windows? Also, what's the base OS of that image, Alpine or some other Linux?

daimor commented 1 month ago

Docker on WSL this one is not alpine, with alpine isclexer does not work

isc-bsaviano commented 1 month ago

I was able to reproduce this with the node:20 container image on WSL and using Docker Desktop on my mac. Looks like the image uses Debian and not Ubuntu. I think our Linux binaries are built on Ubuntu. I wonder if that could be a cause.