Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum recursion depth exceeded due to self-reference in associate statement #433

Open
Friedinho opened this issue Oct 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Friedinho
Copy link

Friedinho commented Oct 14, 2024

I encountered an issue, where an accidental self reference in an associate statement lead to crashing the language server. Maybe this is not a classical bug, but it would be nice, if it is catched somehow.

The error stated that the maximum recursion depth exceeded. Since I did not know, where the error came from, I increased the depth limit. The error then showed that the language server failed to create a connection.

I my (relative) large program, the server did not responed and I could not use ay features, such as hover or jump to subroutines. Creating a minimal working example, it shows the error, but it still workes kind of. Try to hover over the associate(realsAndIntegers => realsAndIntegers) within this program:

module someTypes
   implicit none
   private

   public integer_type
   public realAndInteger_type
   
   type integer_type
   integer(4) :: a
   end type integer_type
   
   type realAndInteger_type
   real(8) :: b
   type(integer_type) :: c
   end type realAndInteger_type
end module someTypes

module errorModule
   use someTypes
   
   implicit none
   private
   
   public error_inHere
contains
   subroutine error_inHere(realsAndIntegers, integers)
   type(realAndInteger_type), intent(inout) :: realsAndIntegers
   type(integer_type),               intent(inout) :: integers
      ! error here !
      associate(realsAndIntegers => realsAndIntegers)
         realsAndIntegers%b = 1.0
         realsAndIntegers%c%a = 1
      end associate
      integers%a = 2
   end subroutine error_inHere
end module errorModule


program error_main

use someTypes
use errorModule

implicit none

type(integer_type)               :: my_integers
type(realAndInteger_type) :: my_realsAndIntegers

   call error_inHere(my_realsAndIntegers, my_integers)
   print *, my_integers%a
   print *, my_realsAndIntegers%b, my_realsAndIntegers%c%a

end program error_main

The error is within the minimal example:

[Error - 10:45:31 AM] Request textDocument/hover failed.
  Message: maximum recursion depth exceeded
  Code: -32603 
[object Object]
[WARN - 10:45:31] error handling request {'jsonrpc': '2.0', 'id': 1290, 'method': 'textDocument/hover', 'params': {'textDocument': {'uri': 'file:///home/jf/Desktop/temp/modernFortran_fail/error_main.F90'}, 'position': {'line': 31, 'character': 22}}}
Traceback (most recent call last):
  File "/home/jf/.local/lib/python3.9/site-packages/fortls/langserver.py", line 173, in handle
    resp = handler(request)
  File "/home/jf/.local/lib/python3.9/site-packages/fortls/langserver.py", line 1112, in serve_hover
    var_type: int = var_obj.get_type()
  File "/home/jf/.local/lib/python3.9/site-packages/fortls/parsers/internal/variable.py", line 89, in get_type
    return self.link_obj.get_type()
  File "/home/jf/.local/lib/python3.9/site-packages/fortls/parsers/internal/variable.py", line 89, in get_type
    return self.link_obj.get_type()
  File "/home/jf/.local/lib/python3.9/site-packages/fortls/parsers/internal/variable.py", line 89, in get_type
    return self.link_obj.get_type()
  [Previous line repeated 992 more times]
RecursionError: maximum recursion depth exceeded

The error code produced with my actual program is a little bit longer and the location of the erorr was not shown.
The system is openSUSE Leap 15.4 with VSCode 1.92.4, fortls 3.1.2, Modern Fortran v3.4.2024090901 and gfortran 12.0 compiler. I am using the standard settings and do not have any special configurations, which may affect the error.

@Friedinho Friedinho added the bug Something isn't working label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant