[GHC] #12527: GHC segfault while linking llvm-general while compiling a file using Template Haskell

#12527: GHC segfault while linking llvm-general while compiling a file using Template Haskell -------------------------------------+------------------------------------- Reporter: HMPerson1 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If I have a file {{{#!hs -- Lib.hs module Lib where [d| foo = 1 |] }}} and I add `llvm-general` as a dependency, compiling with -v yields the attached log, followed by `segmentation fault (core dumped)`. Investigating with gdb, the back trace is {{{ ... Loading package llvm-general-3.5.1.2 ... linking ... Thread 1 "ghc" received signal SIGSEGV, Segmentation fault. 0x000000004490f604 in ?? () (gdb) bt #0 0x000000004490f604 in ?? () #1 0x0000000044a8798d in ?? () #2 0x0000000000000132 in ?? () #3 0x0000000044a98b38 in ?? () #4 0x0000000044a87b30 in ?? () #5 0x00007fffeed667b1 in ocRunInit_ELF (oc=0xf7f520) at rts/Linker.c:6198 #6 resolveObjs_ () at rts/Linker.c:3196 #7 resolveObjs () at rts/Linker.c:3218 #8 0x00007ffff5eb03a3 in ?? () from /home/michael/.stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/bin/../ghc_0AG9TOjDEtx4Ji3wSwHOBe/libHSghc-7.10.3 -0AG9TOjDEtx4Ji3wSwHOBe-ghc7.10.3.so #9 0x0000000000000000 in ?? () }}} Note that without the quasi-quotation in `Lib.hs` it will compile fine, and without the `llvm-general` dependency it will also compile fine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12527 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12527: GHC segfault while linking llvm-general while compiling a file using Template Haskell -------------------------------------+------------------------------------- Reporter: HMPerson1 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by HMPerson1): * Attachment "crash.log" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12527 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12527: GHC segfault while linking llvm-general while compiling a file using Template Haskell -------------------------------------+------------------------------------- Reporter: HMPerson1 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): It looks like a bug in the ghci linker. As a workaround I suggest you try building llvm-general with its cabal flag `-fshared-llvm`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12527#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12527: GHC segfault while linking llvm-general while compiling a file using Template Haskell -------------------------------------+------------------------------------- Reporter: HMPerson1 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): I could reproduce this just by running `ghci -package llvm-general`. What's going on here is that the ghci linker is loading an archive that contains two object files, let's call them `A.o` and `B.o`. For whatever reason ghci processes `A.o` before `B.o`. Now `A.o` has an `.init_array` section that contains a function that eventually calls a function defined in `B.o`. The problem is that `resolveObjs_` works like this: for each object file, resolve its relocations and then run its initializers so `B.o` hasn't had its relocations resolved when the initializer of `A.o` runs and tries to call a function defined in `B.o`. Seems like it should instead work like this: for each object file, resolve its relocations for each object file, run its initializers -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12527#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC