Skip to content

Redundant symbol containing Unicode character may cause HLS to hang #2859

New issue

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

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

Already on GitHub? # to your account

Closed
konn opened this issue Apr 27, 2022 · 2 comments · Fixed by #2870
Closed

Redundant symbol containing Unicode character may cause HLS to hang #2859

konn opened this issue Apr 27, 2022 · 2 comments · Fixed by #2870
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@konn
Copy link
Collaborator

konn commented Apr 27, 2022

Your environment

  • Which OS do you use: Ubuntu 20.04.2 LTS
  • Which LSP client (editor/plugin) do you use: VSCode + vscode-haskell
  • Describe your project (alternative: link to the project): A simple project using GHC 9.02 consisting of the following two modules:

    • Types.hs:

      module Types where
      
      ε :: Double
      ε = 0.5
      
      data A = A
    • Lib.hs

      {-# OPTIONS_GHC -Wall #-}
      module Lib where
      import Types (A (..), ε)
      
      a :: A
      a = A

Steps to reproduce

  1. Open Lib.hs and wait a moment.
  2. Warning on redundant import of ε gets reported and HLS stops responding.

Expected behaviour

HLS should continue working and provide some code action to remove ε from the list.

Actual behaviour

HLS hangs and stop responding indefinitely.

If we rename ε so that it doesn't include any unicode character, then the panic goes away.
Also note that removing the definition of a from Lib.hs and stop importing A(..), then HLS won't panic anymore - it seems that at least one extra imported item are needed to reproduce the situation. In other words, the following Lib.hs won't make HLS panic:

{-# OPTIONS_GHC -Wall #-}
module Lib where

import Types (ε)

Include debug information

Debug Output here:

panic.log

The following panic lines from the above illustrates the situation:

haskell-language-server-9.0.2: haskell-language-server-9.0.2: panic! (the 'impossible' happened)
  (GHC version 9.0.2:
	charType: '\949'

\949 corresponds to ε.

@konn konn added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage component: ghcide labels Apr 27, 2022
@konn
Copy link
Collaborator Author

konn commented Apr 27, 2022

It seems that it also occurs with "add missing import" code action.

@drsooch
Copy link
Collaborator

drsooch commented Apr 30, 2022

Yep, I see the issue. is_ident in wrapOperatorInParens panics on non-ascii chars. I'll make a PR in the next few days.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants