[GHC] #16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l"

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ----------------------------------------+--------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: MacOS X Architecture: Unknown/Multiple | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: ----------------------------------------+--------------------------------- When building the latest `opencv-extra` library on OS X I'm getting a GHC panic. To reproduce git clone https://github.com/LumiGuide/haskell-opencv, make sure Nix is installed and execute: {{{
nix-build -A haskellPackages.opencv-extra ... [11 of 11] Compiling OpenCV.Extra ( src/OpenCV/Extra.hs, dist/build/OpenCV/Extra.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.6.3 for x86_64-apple-darwin): Data.Binary.Get.runGet at position 8: Invalid magic number "INPUT(-l" CallStack (from HasCallStack): error, called at libraries/binary/src/Data/Binary/Get.hs:351:5 in binary-0.8.6.0:Data.Binary.Get }}}
The library builds successfully on Linux. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by domenkozar): Upstream issue: https://gitlab.com/twittner/bytestring-conversion/issues/2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by mpickering): Looks like a darwin specific issue, perhaps even a nix on darwin specific issue. I can't reproduce this on NixOS. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by mpickering): I an reproduce this with nix on darwin though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by basvandijk): I was able to create a minimal test-case for this. Please have a look at: https://github.com/basvandijk/macos-ghc863-panic -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Changes (by basvandijk): * priority: normal => high Old description:
When building the latest `opencv-extra` library on OS X I'm getting a GHC panic. To reproduce git clone https://github.com/LumiGuide/haskell- opencv, make sure Nix is installed and execute:
{{{
nix-build -A haskellPackages.opencv-extra ... [11 of 11] Compiling OpenCV.Extra ( src/OpenCV/Extra.hs, dist/build/OpenCV/Extra.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.6.3 for x86_64-apple-darwin): Data.Binary.Get.runGet at position 8: Invalid magic number "INPUT(-l" CallStack (from HasCallStack): error, called at libraries/binary/src/Data/Binary/Get.hs:351:5 in binary-0.8.6.0:Data.Binary.Get }}}
The library builds successfully on Linux.
New description: When building the latest `opencv-extra` library on OS X I'm getting a GHC panic. To reproduce git clone https://github.com/LumiGuide/haskell-opencv, make sure Nix is installed and execute: {{{
nix-build -A haskellPackages.opencv-extra ... [11 of 11] Compiling OpenCV.Extra ( src/OpenCV/Extra.hs, dist/build/OpenCV/Extra.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.6.3 for x86_64-apple-darwin): Data.Binary.Get.runGet at position 8: Invalid magic number "INPUT(-l" CallStack (from HasCallStack): error, called at libraries/binary/src/Data/Binary/Get.hs:351:5 in binary-0.8.6.0:Data.Binary.Get }}}
The library builds successfully on Linux. Minimal test case: https://github.com/basvandijk/macos-ghc863-panic -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by basvandijk): As I just mentioned in the [https://github.com/basvandijk/macos- ghc863-panic#observations README] I discovered that the panic is caused by a `ghc -staticlib` invocation. When I disable building a static library the build succeeds. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by basvandijk): Corresponding [https://github.com/NixOS/nixpkgs/issues/55848 NixOS issue #55848]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

cat /nix/store/jv40yw2ny28nnpbf860aaqq1dhga0f0r-
#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by basvandijk): As I [https://github.com/NixOS/nixpkgs/issues/55848#issuecomment-464212640 just discovered], apparently my `libc++.a` in my Nix store contains the following: {{{ libc++-5.0.2/lib/libc++.a INPUT(-lc++_static -lc++abi) }}} Note that the first 8 bytes of this file are `INPUT(-` which is exactly what GHC is panicking about. It seems that GHC is expecting `libc++.a` to be a binary archive while in fact it's some kind of textual reference to the real archive `libc++_static.a` which can be found in the same directory. Are these textual archive file a Nix-specific thing that GHC doesn't support? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by basvandijk): Ok so on Nix `libc++.a` is an [https://sourceware.org/binutils/docs/ld /Implicit-Linker-Scripts.html#Implicit-Linker-Scripts implicit linker script]: `INPUT(-lc++_static -lc++abi)`. Maybe we should give GHC support for linker scripts. Initially it could just support the [https://sourceware.org/binutils/docs/ld/File- Commands.html#File-Commands INPUT] command. This shouldn't be that hard. [https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/main/Ar.hs compiler/main/Ar.hs] needs to be adapted. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by basvandijk): Here's some work-in-progress on this: https://github.com/basvandijk/ghc/commit/79f71de60f3eda37f552bfcb98a440da69c... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16130: GHC Panic on OS X: Data.Binary.Get.runGet: Invalid magic number "INPUT(-l" ---------------------------------+---------------------------------------- Reporter: basvandijk | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+---------------------------------------- Comment (by basvandijk): I can confirm that [https://github.com/basvandijk/ghc/commit/b2b92dde16275339293cedaa94d6745e69e... this patch] fixes this issue. Both [https://github.com/basvandijk/macos- ghc863-panic macos-ghc863-panic], `bytestring-conversion` and `opencv- extra` build successfully with this patch and fail to build without it. Next up is adding a test for this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16130#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC