AdaCore / ada_language_server

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

[Bug]: Generics trigger STALE_REFERENCE_ERROR #1219

Open ckankare opened 2 weeks ago

ckankare commented 2 weeks ago

Environment

Bug Summary and Reproducer

Bug Summary:

Generics causes the language server to crash with

Message: Exception: raised LANGKIT_SUPPORT.ERRORS.STALE_REFERENCE_ERROR : related unit was reparsed

Steps to reproduce:

With the following file

procedure Main is

   generic

   type Value_T is private;

   package Foos is

      Value : Value_T;

   end Foos;

   package Bars is new Foos (Integer);

begin
    Bars.Value := 10;
end;

add a space somewhere (or something that triggers textDocument/semanticTokens/full), this causes the language server to crash with the following error:

[Error - 8:52:59 PM] Request textDocument/semanticTokens/full failed.
  Message: Exception: raised LANGKIT_SUPPORT.ERRORS.STALE_REFERENCE_ERROR : related unit was reparsed

and the following stack trace:

0x563b972166de Libadalang.Analysis.Check_Safety_Net.Localalias at libadalang-analysis.adb:36610
0x563b9725f146 Libadalang.Analysis.P_Decl at libadalang-analysis.adb:24221
0x563b9690bb9b Lsp.Ada_Highlighters.Highlight_Name at lsp-ada_highlighters.adb:571
0x563b9690d57c Lsp.Ada_Highlighters.Highlight_Node at lsp-ada_highlighters.adb:855
0x563b96acf734 Lsp.Ada_Tokens_Full.Execute_Ada_Request at lsp-ada_tokens_full.adb:114
0x563b95d49023 Lsp.Ada_Request_Jobs.Execute_Request at lsp-ada_request_jobs.adb:33
0x563b95d48df9 Lsp.Server_Request_Jobs.Execute at lsp-server_request_jobs.adb:46
0x563b95d228ff Lsp.Job_Schedulers.Process_Job at lsp-job_schedulers.adb:183
0x563b96a59d4a Lsp.Servers.Processing_Task_TypeT at lsp-servers.adb:847
0x563b98c1dbed system__tasking__stages__task_wrapper at ???

Attached reproducible case and ALS log file. als_bug_1.zip ada_ls_log.2024-10-24T211228.log

Configuration and Logs

-

Other VS Code Extensions

No response

Additional context

No response

ec-c commented 2 weeks ago

I can confirm this bug using:

reznikmm commented 1 week ago

This is fixed in the development version (actually in libadalang)