AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
238 stars 55 forks source link

Constraint_Error in ALS from vscode when reading Ada code #1194

Open stcarrez opened 6 months ago

stcarrez commented 6 months ago

With version 24.0.5, I'm seeing CONSTRAINT_ERROR from vscode when looking at some Ada file that compiles. It occurs for one file but not for others. The file is correct and compiles. The issue occurs when moving the caret at some position in the buffer by using the mouse (ie, click to position the caret).

2024-05-01 14:29:25.728 [error] Exception: CONSTRAINT_ERROR (LSP.Text_Documents.Line_Marker_Vectors.Constant_Reference: Index is out of range): Error: Exception: CONSTRAINT_ERROR (LSP.Text_Documents.Line_Marker_Vectors.Constant_Reference: Index is out of range)
    at dr (/home/ciceron/.vscode/extensions/adacore.ada-24.0.5/out/src/extension.js:36:228)
    at xr (/home/ciceron/.vscode/extensions/adacore.ada-24.0.5/out/src/extension.js:35:6240)
    at lr (/home/ciceron/.vscode/extensions/adacore.ada-24.0.5/out/src/extension.js:35:6363)
    at Immediate.<anonymous> (/home/ciceron/.vscode/extensions/adacore.ada-24.0.5/out/src/extension.js:35:6127)
    at process.processImmediate (node:internal/timers:476:21)

Each time there is such exception, vscode displays the popup with message Request textDocument/foldingRange failed..

The log file /home/ciceron/.config/Code/logs/20240428T113411/window1/exthost/exthost.log indicates the above exception (several times) but there is no other information.

AnthonyLeonardoGracio commented 6 months ago

Hello @stcarrez ,

As said on the other issue, having the logs produced by the Ada Language Server itself in the ~/.als folder would help a lot, if you could attach them.

Regards,

stcarrez commented 6 months ago

See exthost.log

AnthonyLeonardoGracio commented 5 months ago

Hello @stcarrez,

This is the log coming from VS Code itself, which does not help much here: we really need the logs present in the ~/.als folder, which are emitted by the Ada Language Server executable itself.

Regards,

stcarrez commented 5 months ago

Again, there is no ~/.als folder on Linux. If I create manually that directory, it is populated by empty files like:

ls -la ~/.als/
total 8
drwxrwxr-x  2 ciceron ciceron 4096 juin  15 10:31 .
drwxr-xr-x 78 ciceron ciceron 4096 juin  15 09:53 ..
-rw-rw-r--  1 ciceron ciceron    0 juin  14 23:09 als.2024-06-14T230920.2911985.log
-rw-rw-r--  1 ciceron ciceron    0 juin  14 23:09 als.2024-06-14T230920.2911986.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:06 als.2024-06-15T100612.2935280.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:06 als.2024-06-15T100612.2935282.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:24 als.2024-06-15T102424.2937842.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:24 als.2024-06-15T102424.2937844.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:28 als.2024-06-15T102833.2939281.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:28 als.2024-06-15T102833.2939283.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:30 als.2024-06-15T103052.2940267.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:30 als.2024-06-15T103052.2940269.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:31 als.2024-06-15T103118.2940687.log
-rw-rw-r--  1 ciceron ciceron    0 juin  15 10:31 als.2024-06-15T103118.2940689.log

Either this is not supported by the binary shipped with the VScode plugin, or, there is some option that I'm not aware of to enable that.

AnthonyLeonardoGracio commented 5 months ago

Hmm really strange, normally the directory is created by default. In any case, just add a traces.cfg file in this ~/.als folder, with the following contents:

>als.$T.txt:buffer_size=0:buffer_size=0
ALS.MAIN=yes
## uncomment the following 2 lines to activate full traces
ALS.IN=yes
ALS.OUT=yes

With this file you will get non-empty log files, normally.

We will investigate on why this folder does not get created by default.

Regards,