Hard ghc api crash when calling runStmt on code which has not been compiled
(See attached example program demonstrating the crash.) When the session flags are set to
let flags = flags0 { hscTarget = HscNothing, ghcLink = NoLink } -- Crashes
and we later try to run the code (runStmt
), the GHC API crashes. If instead we set the flags to
let flags = flags0 { hscTarget = HscNothing, ghcLink = LinkBinary } -- Okay
we get a nice error message instead:
Undefined symbols for architecture i386:
"_ZCMain_main_closure", referenced from:
_main in ghc72975_0.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
TestGhc: TestGhc: phase `Linker' failed (exitcode = 1)
The exact crash varies from run to run. Most often it is
Bus error: 10
Sometimes it is
Segmentation fault: 11
and in all my testing I've only once seen
TestGhc: internal error: stg_ap_v_ret
(GHC version 7.4.2 for i386_apple_darwin)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Abort trap: 6
(This is on a Mac, confirmed with both ghc 7.4 and ghc 7.6).
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |