fpco / ide-backend

ide-backend drives the GHC API to build, query, and run your code
120 stars 17 forks source link

Server dies when unloading bad C code #201

Closed snoyberg closed 10 years ago

snoyberg commented 10 years ago

Original issue: https://github.com/fpco/fpco/issues/3681

Code at: https://gist.github.com/b6840983c5b46f2b888f.git

The basic idea is that we add a valid C file, then replace it with invalid code, then fix it, and the ide-backend-server process panics while unloading. The output I get when running this Gist is:

$ runghc Main.hs 
[1 of 2] Compiling test.c
[2 of 2] Loading test.o
[3 of 3] Compiling Main
[]
"42\n"
RunOk
[1 of 3] Unloading test.o
[2 of 3] Compiling test.c
[3 of 3] Skipped loading test.o
[SourceError {errorKind = KindError, errorSpan = <gcc error>, errorMsg = "\n/home/ubuntu/Desktop/b6840983c5b46f2b888f/session.11318/src/test.c:1:1:\n     error: expected \8216=\8217, \8216,\8217, \8216;\8217, \8216asm\8217 or \8216__attribute__\8217 at end of input\n"}]
[1 of 3] Unloading test.o
ide-backend-server: unloadObj: can't find `/home/ubuntu/Desktop/b6840983c5b46f2b888f/session.11318/ffi/test.o' to unload
[SourceError {errorKind = KindServerDied, errorSpan = <<server died>>, errorMsg = "ide-backend-server: panic! (the 'impossible' happened)\n  (GHC version 7.4.2.20140313 for x86_64-unknown-linux):\n\tunloadObj \"/home/ubuntu/Desktop/b6840983c5b46f2b888f/session.11318/ffi/test.o\": failed\n\nPlease report this as a GHC bug:  http://www.haskell.org/ghc/reportabug\n"}]
edsko commented 10 years ago

Taking a look.

edsko commented 10 years ago

@snoyberg I have pushed a fix for this to experimental, and rebased fork-snippets. Closing this issue. Let me know if it does not resolve the issue for you.

snoyberg commented 10 years ago

Appears to be working now, thanks for the fast patch!