-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Fix crash on completion with type family #2569
Fix crash on completion with type family #2569
Conversation
Close haskell#2404. `tcdLName` is partial for type/data families, its a record field accessor which is not defined for all cases of the `TyClDecl` type. Instead we use `tyClDeclLName` which will look for the name through an indirection.
edit: sorry, I linked the wrong bug, this is fixed now, but if you read the issue from your email, you won't see the change. |
I'm not providing a regression test, I'm sorry. Thing is, I don't really see how I can write a regression test which tests that the server does not ends in a weird state when asking for completion for a type family. I'll be super happy to contribute that if you give me a few guidance with the test infrastructure. However the fix is so simple and obvious that, well, a test may not be necessary ;) (Don't do this at home kids, we are trained engineers here ;) |
I'm not sure I understand the CI failure. Guidance will be appreciated. |
The failure didn't look related. We have a couple of flakey tests that fail non-deterministically and this was one of them. I have triggered another run |
The purpose of the test is to ensure that the codebase doesn't regress in the future, which could happen quite easily as the GHC api tends to change a lot across releases. |
Just by writing a test that triggers the completion and checks the results. There are a couple of completion tests already at |
@pepeiborra so we could merge it or should wait for the regression test? |
Thank you. I tried to write a regression test, using the following:
Unfortunately, it times out. However, if I replace I tried to add logging using
But the test still timeouts. I also tried:
Which also timeout. But if I replace How could I debug / understand the timeout? I tried to run the test with |
Did you try setting the |
Thank you! And now the error appears, and it is still |
Actually, the test were using the I need to understand how the test are supposed to be run so they use the correct HLS and then I'll push my regression test. |
Ok, found, |
Thank a lot to all of you for the help and guidance, I've pushed an MR with regression tests.
@pepeiborra, Sorry, you are perfectly right. I took that lightly, but indeed there is nothing as a "so simple fix that it does not need regression test". Now that I got how tests works, next PR will have tests. Thank you for the remainder. |
Close #2403.
tcdLName
is partial for type/data families, its a record fieldaccessor which is not defined for all cases of the
TyClDecl
type.Instead we use
tyClDeclLName
which will look for the name through anindirection.
Note: I've checked that it works with GHC 8.10.7. The symbol is available starting from GHC 8.2: https://hackage.haskell.org/package/ghc-8.2.1/docs/HsDecls.html#v:tyClDeclLName so it should be compatible (minor the change in the module hierarchy, we'll see how the CI behaves).
Side question: I was able to remove the failure observed in #2403. However this bug was a pain to diagnostic. I'm experimenting random failures with HLS and I was used to restart my HLS session because HLS does not crash, it just stops responding.
I suspect (but that's pure guess) that a thread is launched, crashs (because of the exception, which is actually correctly sent to lsp log of my editor), but HLS is never restored in a working state. There is on
forkIO
in the codebase which may be responsible for it, and onforkFinally
, which is supposed to crash the server withFatal error in server thread
which is not sent to my client. Maybe an issue should be opened to discuss that matter, I rather prefer to see a fully crashed HLS than a zombie processus ;)