Skip to content

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

Open
@cobalamin

Description

@cobalamin

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 <ghc-process-id> 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 #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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions