Skip to content

Bad magic in static (FFI) object (7.6.1 for x86_64-apple-darwin)

When spraying HOC (Haskell to Objective-C) for bitrot, I encountered a GHC panic during the loading of some FFI.

Judging by the log below, it looks like this is during a TH execution, so the problem may be bitrot in this code wrt TH. Quite happy to dig further myself if pointed in the right direction.

Orac:~/work/hoc-read-only/hoc $ cabal build
Compiling HOC_cbits...
Building HOC-1.0...
Preprocessing library HOC-1.0...
[16 of 31] Compiling HOC.Invocation   ( HOC/HOC/Invocation.hs, dist/build/HOC/Invocation.o )

HOC/HOC/Invocation.hs:14:1:
    Unacceptable argument type in foreign declaration: FFICif
    When checking declaration:
      foreign import ccall safe "static Invocation.h callWithExceptions" c_callWithExceptions
        :: FFICif
           -> FunPtr a -> Ptr b -> Ptr (Ptr ()) -> IO (Ptr ObjCObject)
Orac:~/work/hoc-read-only/hoc $ cabal build
Compiling HOC_cbits...
Building HOC-1.0...
Preprocessing library HOC-1.0...
[ 7 of 31] Compiling HOC.FFICallInterface ( HOC/HOC/FFICallInterface.hs, dist/build/HOC/FFICallInterface.o )
[ 8 of 31] Compiling HOC.Arguments    ( HOC/HOC/Arguments.hs, dist/build/HOC/Arguments.o ) [HOC.FFICallInterface changed]
[11 of 31] Compiling HOC.CStruct      ( HOC/HOC/CStruct.hs, dist/build/HOC/CStruct.o ) [HOC.FFICallInterface changed]
[13 of 31] Compiling HOC.ID           ( HOC/HOC/ID.hs, dist/build/HOC/ID.o ) [HOC.FFICallInterface changed]
[16 of 31] Compiling HOC.Invocation   ( HOC/HOC/Invocation.hs, dist/build/HOC/Invocation.o )
[17 of 31] Compiling HOC.ExternFunctions ( HOC/HOC/ExternFunctions.hs, dist/build/HOC/ExternFunctions.o )

HOC/HOC/ExternFunctions.hs:77:34:
    Ambiguous occurrence `unsafePerformIO'
    It could refer to either `Foreign.unsafePerformIO',
                             imported from `Foreign' at HOC/HOC/ExternFunctions.hs:10:1-14
                          or `System.IO.Unsafe.unsafePerformIO',
                             imported from `System.IO.Unsafe' at HOC/HOC/ExternFunctions.hs:11:1-23
                             (and originally defined in `GHC.IO')
Orac:~/work/hoc-read-only/hoc $ cabal build
Compiling HOC_cbits...
Building HOC-1.0...
Preprocessing library HOC-1.0...
[17 of 31] Compiling HOC.ExternFunctions ( HOC/HOC/ExternFunctions.hs, dist/build/HOC/ExternFunctions.o )
[18 of 31] Compiling HOC.StdArgumentTypes ( HOC/HOC/StdArgumentTypes.hs, dist/build/HOC/StdArgumentTypes.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package containers-0.5.0.0 ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package syb-0.3.7 ... linking ... done.
Loading package bytestring-0.10.0.0 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package text-0.11.2.3 ... linking ... done.
Loading package parsec-3.1.3 ... linking ... done.
Loading package old-locale-1.0.0.5 ... linking ... done.
Loading package old-time-1.1.0.1 ... linking ... done.
Loading package fgl-5.4.2.4 ... linking ... done.
Loading package filepath-1.3.0.1 ... linking ... done.
Loading package time-1.4.0.1 ... linking ... done.
Loading package unix-2.6.0.0 ... linking ... done.
Loading package directory-1.2.0.0 ... linking ... done.
Loading package binary-0.5.1.1 ... linking ... done.
Loading package HUnit-1.2.5.1 ... linking ... done.
Loading object (static) dist/build/HOC_cbits.o ... ghc: dist/build/HOC_cbits.o: Bad magic. Expected: feedfacf, got: feedface.

ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.1 for x86_64-apple-darwin):
	loadObj "dist/build/HOC_cbits.o": failed

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information