AdaCore / ada_language_server

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

textDocument/declaration error (LANGKIT_SUPPORT.ERRORS.PROPERTY_ERROR) #756

Closed timlag1305 closed 3 years ago

timlag1305 commented 3 years ago

Hi,

I am using ada_language_server that I compiled from the gnat community 2021 sources. I am running into an error that prevents me from navigating to a declaration. You'll see that there is actually an exception opening the Ada file as well. Perhaps this is causing the problem navigating to the declaration.

I am running on Linux. I redacted some info. I haven't tried to reproduce on a simpler example yet, but I can if that's helpful.

[ALS.MAIN] ALS version: 
[ALS.MAIN] Initializing server ...
[ALS.MAIN] Ada version used for predefined completion: ADA_2020
[ALS.IN] {"method": "initialize", "jsonrpc": "2.0", "id": 1, "params": {"initializationOptions": {}, "rootUri": "file:///<REDACTED> [{"uri": "file:///<REDACTED>
[ALS.MAIN] Initialize_Request: Request  1 /<REDACTED>
[ALS.MAIN] Context root: /<REDACTED>
[ALS.MAIN] Initialize_Response: Response  1 
[ALS.OUT] {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"triggerCharacters":[".","("],"resolveProvider":false},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":[",","("],"retriggerCharacters":[" "]},"declarationProvider":true,"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["refactor.rewrite"]},"documentFormattingProvider":true,"renameProvider":{"prepareProvider":true},"foldingRangeProvider":true,"executeCommandProvider":{"commands":["als-other-file","als-named-parameters","als-refactor-imports","als-refactor-remove-parameters","als-refactor-move-parameter","als-refactor-change-parameter-mode","als-suppress-separate"]},"workspaceSymbolProvider":true,"callHierarchyProvider":{},"alsShowDepsProvider":true,"alsReferenceKinds":["reference","access","write","call","dispatching call","parent","child"]}}}
[ALS.IN] {"method": "initialized", "jsonrpc": "2.0", "params": {}}
[ALS.MAIN] Exit_Notification: 
[ALS.IN] {"method": "workspace/didChangeConfiguration", "jsonrpc": "2.0", "params": {"settings": {"ada": {"renameInComments": "true", "projectFile": "<REDACTED>.gpr", "defaultCharset": "utf-8"}}}}
[ALS.MAIN] DidChangeConfiguration_Notification: ada=(renameInComments=trueprojectFile=waterrower.gprdefaultCharset=utf-8)
[ALS.IN] {"method": "textDocument/didOpen", "jsonrpc": "2.0", "params": {"textDocument": {"uri": "file:///<REDACTED> 0, "languageId": "ada", "text": "<REDACTED>"}}}
[ALS.MAIN] Exception (processing notification):
_ALS.MAIN_ CONSTRAINT_ERROR
_ALS.MAIN_ [/usr/lib/gnatcoll.relocatable/libgnatcoll.so.2021]
_ALS.MAIN_ 0x7f01d0f06555
_ALS.MAIN_ 0x7f01d0f20eac
_ALS.MAIN_ 0x55cd202aa3d6
_ALS.MAIN_ 0x55cd20255c1a
_ALS.MAIN_ 0x55cd2025625a
_ALS.MAIN_ [/usr/lib64/libgnarl-11.so]
_ALS.MAIN_ 0x7f01cfd0836d
_ALS.MAIN_ [/usr/lib64/libpthread.so.0]
_ALS.MAIN_ 0x7f01cf85e257
_ALS.MAIN_ [/usr/lib64/libc.so.6]
_ALS.MAIN_ 0x7f01cf4095e1
_ALS.MAIN_ 0xfffffffffffffffe
[ALS.MAIN] On_DidOpenTextDocument_Notification: file:///<REDACTED>
[ALS.MAIN] In Text_Document_Did_Open
[ALS.MAIN] Uri : file:///<REDACTED>
[ALS.MAIN] Project loading ...
[ALS.MAIN] Root : /<REDACTED>
[ALS.MAIN] Loading the implicit project
[ALS.MAIN] Finished Text_Document_Did_Open
[ALS.MAIN] Publish_Diagnostics: file:///<REDACTED>
[ALS.OUT] {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///<REDACTED>[]}}
[ALS.MAIN] WorkDoneProgress_Create_Request: Request  2 ada_ls-18509-indexing-1
[ALS.OUT] {"jsonrpc":"2.0","id":2,"method":"window/workDoneProgress/create","params":{"token":"ada_ls-18509-indexing-1"}}
[ALS.MAIN] Progress_Begin: ada_ls-18509-indexing-1
[ALS.OUT] {"jsonrpc":"2.0","method":"$/progress","params":{"token":"ada_ls-18509-indexing-1","value":{"kind":"begin","title":"Indexing","percentage":0}}}
[ALS.MAIN] Progress_Report: ada_ls-18509-indexing-1
[ALS.OUT] {"jsonrpc":"2.0","method":"$/progress","params":{"token":"ada_ls-18509-indexing-1","value":{"kind":"report","percentage":50}}}
[ALS.MAIN] Progress_End: ada_ls-18509-indexing-1
[ALS.IN] {"id": 2, "result": null, "jsonrpc": "2.0"}
[ALS.OUT] {"jsonrpc":"2.0","method":"$/progress","params":{"token":"ada_ls-18509-indexing-1","value":{"kind":"end"}}}
[ALS.IN] {"method": "textDocument/declaration", "jsonrpc": "2.0", "id": 2, "params": {"textDocument": {"uri": "file:///<REDACTED> {"character": 41, "line": 28}}}
[ALS.MAIN] Declaration_Request: Request  2 file:///<REDACTED>28:41
[ALS.MAIN] LANGKIT_SUPPORT.ERRORS.PROPERTY_ERROR: dispatching on null node
_ALS.MAIN_ [/usr/lib/libadalang.relocatable/libadalang.so]
_ALS.MAIN_ 0x7f01d20141e8
_ALS.MAIN_ 0x7f01d2017dfb
_ALS.MAIN_ 0x7f01d20188bc
_ALS.MAIN_ [/usr/lib/langkit_support.relocatable/liblangkit_support.so]
_ALS.MAIN_ 0x7f01d12e6abb
_ALS.MAIN_ 0x7f01d12f5ab4
_ALS.MAIN_ 0x7f01d12e6abb
_ALS.MAIN_ 0x7f01d12e6bfd
_ALS.MAIN_ [/usr/lib/libadalang.relocatable/libadalang.so]
_ALS.MAIN_ 0x7f01d1f3f889
_ALS.MAIN_ 0x7f01d1d88f64
_ALS.MAIN_ 0x7f01d1f9bdb1
_ALS.MAIN_ 0x7f01d1f9be96
_ALS.MAIN_ 0x7f01d1f9be96
_ALS.MAIN_ 0x7f01d1f9be96
_ALS.MAIN_ 0x7f01d1f9c0d3
_ALS.MAIN_ 0x7f01d1fe8033
_ALS.MAIN_ 0x7f01d1fe858f
_ALS.MAIN_ 0x7f01d1fec3f9
_ALS.MAIN_ 0x7f01d1b9bb1a
_ALS.MAIN_ [/usr/lib/lal_tools.relocatable/liblal_tools.so]
_ALS.MAIN_ 0x7f01d2bde1e1
_ALS.MAIN_ 0x55cd202014f2
_ALS.MAIN_ 0x55cd202b1579
_ALS.MAIN_ 0x55cd20261302
_ALS.MAIN_ 0x55cd202462cb
_ALS.MAIN_ 0x55cd2025593c
_ALS.MAIN_ 0x55cd2025625a
_ALS.MAIN_ [/usr/lib64/libgnarl-11.so]
_ALS.MAIN_ 0x7f01cfd0836d
_ALS.MAIN_ [/usr/lib64/libpthread.so.0]
_ALS.MAIN_ 0x7f01cf85e257
_ALS.MAIN_ [/usr/lib64/libc.so.6]
_ALS.MAIN_ 0x7f01cf4095e1
_ALS.MAIN_ 0xfffffffffffffffe
[ALS.MAIN] Location_Response: Response  2  Locations 0
[ALS.OUT] {"jsonrpc":"2.0","id":2,"result":[]}
reznikmm commented 3 years ago

hello @timlag1305

Have you tried prebuilt Ada Language Server from the VSCode extension? Does it produce the same result?

Our prebuilt Ada Language Server contains the latest version of libgpr, gnatcoll, libadalang and other dependencies with some errors fixed since GNAT Community 2021 Edition release.

The CONSTRAINT_ERROR is unexpected. Can you send us symbolic backtrace for it?

On the other side PROPERTY_ERROR may not mean ALS error. It means that Libadalang is unable to process your code. It could be error in libadalang or else your code is incorrect.

Could you provide the complete reproducer?

timlag1305 commented 3 years ago

Using the prebuilt version from the VSCode extension works correctly. I will work on getting a backtrace of the community release.

timlag1305 commented 3 years ago

I recompiled als and some of its dependencies with debug options. I wasn't able to obtain the complete symbolic backtrace (not sure why) but there is more information.

[ALS.MAIN] Exception (processing notification):
_ALS.MAIN_ SYSTEM.ASSERTIONS.ASSERT_FAILURE
_ALS.MAIN_ [/usr/lib64/libgnat-11.so]
_ALS.MAIN_ 0x7f53a34ebbb2
_ALS.MAIN_ [/usr/lib/gnatcoll.relocatable/libgnatcoll.so.2021]
_ALS.MAIN_ 0x7f53a49c7e10 gnatcoll__json__get__12 at ???
_ALS.MAIN_ 0x556f10e7395b
_ALS.MAIN_ 0x556f108f2ba3
_ALS.MAIN_ 0x556f10df733a
_ALS.MAIN_ 0x556f10df6790
_ALS.MAIN_ [/usr/lib64/libgnarl-11.so]
_ALS.MAIN_ 0x7f53a36e636d
_ALS.MAIN_ [/usr/lib64/libpthread.so.0]
_ALS.MAIN_ 0x7f53a323c257
_ALS.MAIN_ [/usr/lib64/libc.so.6]
_ALS.MAIN_ 0x7f53a2de75e1
_ALS.MAIN_ 0xfffffffffffffffe
[ALS.MAIN] On_DidOpenTextDocument_Notification: file:///home/tim/projects/waterrower/src/api/api.adb
[ALS.MAIN] In Text_Document_Did_Open
timlag1305 commented 3 years ago

I recreated the simplest example I could and still ran into the problem. I am using the built-in language client of neovim 0.5 if it matters.

I created a simple gpr file, empty Makefile, and procedure. See gist: https://gist.github.com/timlag1305/c8ebc4a2eb2b82737f93c18b938dca26

The directory structure is as shown:

.
├── Makefile
├── src
│   └── main.adb
└── test.gpr

1 directory, 3 files

Here is the error:

[ALS.IN] {"method": "workspace/didChangeConfiguration", "jsonrpc": "2.0", "params": {"settings": {"ada": {"renameInComments": "true", "projectFile": "test.gpr", "enableDiagnostics": "true", "defaultCharset": "utf-8"}}}}
[ALS.MAIN] DidChangeConfiguration_Notification: ada=(renameInComments=trueprojectFile=test.gprenableDiagnostics=truedefaultCharset=utf-8)
[ALS.IN] {"method": "textDocument/didOpen", "jsonrpc": "2.0", "params": {"textDocument": {"uri": "file:///home/tim/projects/als_test/src/main.adb", "version": 0, "languageId": "ada", "text": "with Ada.Text_IO;\n\nprocedure Main is\nbegin\n   Ada.Text_IO.Put_Line(\"Test\");\nend Main;\n"}}}
[ALS.MAIN] On_DidOpenTextDocument_Notification: file:///home/tim/projects/als_test/src/main.adb
[ALS.MAIN] Exception (processing notification):
_ALS.MAIN_ SYSTEM.ASSERTIONS.ASSERT_FAILURE
_ALS.MAIN_ [/usr/lib64/libgnat-11.so]
_ALS.MAIN_ 0x7fd2bf32cbb2
_ALS.MAIN_ [/usr/lib/gnatcoll.relocatable/libgnatcoll.so.2021]
_ALS.MAIN_ 0x7fd2c0808e10 gnatcoll__json__get__12 at ???
_ALS.MAIN_ 0x563cf97bc7b3
_ALS.MAIN_ 0x563cf923bba3
_ALS.MAIN_ 0x563cf974033a
_ALS.MAIN_ 0x563cf973f790
_ALS.MAIN_ [/usr/lib64/libgnarl-11.so]
_ALS.MAIN_ 0x7fd2bf52736d
_ALS.MAIN_ [/usr/lib64/libpthread.so.0]
_ALS.MAIN_ 0x7fd2bf07d257
_ALS.MAIN_ [/usr/lib64/libc.so.6]
_ALS.MAIN_ 0x7fd2bec285e1
_ALS.MAIN_ 0xfffffffffffffffe
[ALS.MAIN] In Text_Document_Did_Open
[ALS.MAIN] Uri : file:///home/tim/projects/als_test/src/main.adb
[ALS.MAIN] Project loading ...
[ALS.MAIN] Root : /home/tim/projects/als_test/src/
[ALS.MAIN] Loading the implicit project
[ALS.MAIN] Finished Text_Document_Did_Open
[ALS.MAIN] Publish_Diagnostics: file:///home/tim/projects/als_test/src/main.adb 0
[ALS.OUT] {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/tim/projects/als_test/src/main.adb","diagnostics":[]}}
[ALS.MAIN] WorkDoneProgress_Create_Request: Request  2 ada_ls-53619-indexing-1
[ALS.OUT] {"jsonrpc":"2.0","id":2,"method":"window/workDoneProgress/create","params":{"token":"ada_ls-53619-indexing-1"}}
[ALS.MAIN] Progress_Begin: ada_ls-53619-indexing-1
[ALS.OUT] {"jsonrpc":"2.0","method":"$/progress","params":{"token":"ada_ls-53619-indexing-1","value":{"kind":"begin","title":"Indexing","percentage":0}}}
[ALS.MAIN] Progress_End: ada_ls-53619-indexing-1
[ALS.OUT] {"jsonrpc":"2.0","method":"$/progress","params":{"token":"ada_ls-53619-indexing-1","value":{"kind":"end"}}}
[ALS.IN] {"id": 2, "result": null, "jsonrpc": "2.0"}
reznikmm commented 3 years ago

Hello @timlag1305

The workspace/didChangeConfiguration notification looks suspicious:

Both these properties expected to be boolean type, not a string, so should be written without quotes.

Did you change .vscode/settings.json? Can you check these properties there? It should be

"ada.renameInComments": true

instead of

"ada.renameInComments": "true"
timlag1305 commented 3 years ago

Thanks for the help @reznikmm. Good catch. I am using neovim lsp here. I changed the type from a string to a boolean and that resolved the issue.