haskell / haskell/haskell-mode

haskell-process-get-repl-completions completely hangs Emacs if REPL is inside IO action

Open
#1,332 10 comments 1 reaction 1 assignee Claimed by @geraldus View on GitHub
Dominant language
Emacs Lisp
Stars
1.4k
Forks
354
Avg merge
5d 10h
Merged PRs (30d)
2

Description

I noticed this by using `company-mode` with the `company-ghc` backend. It's an easy way to reproduce this problem.

I have a hook to enable `company-mode` inside `haskell-interactive-mode`. It works great usually, but recently I've noticed that my entire Emacs sometimes freezes up. After some investigation, I noticed that this happens only when I'm inside an IO action and either waiting (`company-mode` by default triggers after a certain amount of time) or triggering the completion manually. A simple `getLine` is enough, but a `forever $ putStrLn ...` loop also works.

I don't think `company-mode` nor `company-ghc` are to blame here, since they seem to simply use `haskell-process-get-repl-completions`. I killed my GHC process and had a look at the log:

```
-> getLine
<- ghc: signal: 15

-> :complete repl "\nasd"
<- 0 0 "\n"

<- ghc: signal: 15
ghc: signal: 15

<- Leaving GHCi.
Leaving GHCi.

Event: "finished
"

Process reset.
```

(everything after `ghc: signal 15` happens when I call `kill ` twice)

I noticed that this `:complete repl ...` call always occurs before REPL+Emacs start hanging. So I looked in my `.emacs.d` for files which send such a command, and `haskell-process.el` in `haskell-mode` showed up, specifically the `haskell-process-get-repl-completions`. And sure enough, when I insert a `(debug)` statement at the top of the function, I can see that this function is called when my problem would occur, and Emacs doesn't start hanging since it's not executing the rest.

This is possibly in some way related to https://github.com/haskell/haskell-mode/issues/871. However, I'm not in multiline mode. To make sure, I explicitly executed `:unset +m` before doing the same thing, and the problem still occurred.

Further info:
- `stack ghc -- --version`: `The Glorious Glasgow Haskell Compilation System, version 7.10.3`
- haskell-mode 20160518.945
- `M-x version`: `GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21) of 2015-04-10 on builder10-9.porkrind.org`
- `M-x eval-expression haskell-process-type`: `stack-ghci`
- `stack --version`: `Version 1.0.4 x86_64`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.