[GHC] #8942: Duplicate symbol error when loading an archive twice

#8942: Duplicate symbol error when loading an archive twice ------------------------------------+------------------------------- Reporter: gelisam | Owner: simonmar Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Keywords: | Operating System: MacOS X Architecture: Unknown/Multiple | Type of failure: GHCi crash Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------- ghci can load packages from object files (*.o) and from archive files (*.a). When an object file is loaded twice, the second attempt is silently ignored. When an archive file is loaded twice, ghci aborts with the message "fatal error: I found a duplicate definition for symbol ''s''", for the first symbol ''s'' in the archive. === Patch The attached patch changes {{{rts/Linker.c}}} so that loading an archive file twice silently ignores the second attempt, just like it does with object files. === Repro steps Install a package using Cabal 1.18.*, as that version only produces archives and not objects. Then, force ghci to load that package twice. One way to do this is to use hint inside ghci to load a value from the package. {{{ $ ghci
import Hello import Language.Haskell.Interpreter r <- runInterpreter $ setImports ["Hello"] >> interpret "Hello" (as :: Hello) 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 filepath-1.3.0.1 ... linking ... done. Loading package old-locale-1.0.0.5 ... linking ... done. Loading package time-1.4.0.1 ... linking ... done. Loading package bytestring-0.10.0.2 ... linking ... done. Loading package unix-2.6.0.1 ... linking ... done. Loading package directory-1.2.0.1 ... linking ... done. Loading package old-time-1.1.0.1 ... linking ... done. Loading package pretty-1.1.1.0 ... linking ... done. Loading package process-1.1.0.2 ... linking ... done. Loading package Cabal-1.16.0 ... linking ... done. Loading package binary-0.5.1.1 ... linking ... done. Loading package bin-package-db-0.0.0.0 ... linking ... done. Loading package hoopl-3.9.0.0 ... linking ... done. Loading package hpc-0.6.0.0 ... linking ... done. Loading package template-haskell ... linking ... done. Loading package ghc-7.6.3 ... linking ... done. Loading package utf8-string-0.3.8 ... linking ... done. Loading package transformers-0.3.0.0 ... linking ... done. Loading package hello-0.1.0.0 ... linking ... done. Loading package mtl-2.1.3.1 ... linking ... done. Loading package exceptions-0.3.3.1 ... linking ... done. Loading package extensible-exceptions-0.1.1.4 ... linking ... done. Loading package ghc-mtl-1.1.0.0 ... linking ... done. Loading package ghc-paths-0.1.0.9 ... linking ... done. Loading package random-1.0.1.1 ... linking ... done. Loading package hint-0.4.0.0 ... linking ... done.
GHCi runtime linker: fatal error: I found a duplicate definition for symbol ___stginit_hellozm0zi1zi0zi0_Hello whilst processing object file /Users/gelisam/.cabal/lib/x86_64-osx- ghc-7.6.3/hello-0.1.0.0/libHShello-0.1.0.0.a This could be caused by: * Loading two different object files which export the same symbol * Specifying the same object file twice on the GHCi command line * An incorrect `package.conf' entry, causing some object to be loaded twice. GHCi cannot safely continue in this situation. Exiting now. Sorry. }}} A minimal definition for the hello package is attached, but doesn't contain anything relevant to the issue. It's just a dummy datatype: {{{#!haskell {-# LANGUAGE DeriveDataTypeable #-} module Hello where import Data.Typeable data Hello = Hello deriving Typeable }}} === Workaround Use Cabal 1.16, which (also) installs object files. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8942 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8942: Duplicate symbol error when loading an archive twice -----------------------------------+------------------------------------ Reporter: gelisam | Owner: simonmar Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: GHCi crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+------------------------------------ Comment (by gelisam): Might be a duplicate of #8614, which has the same symptoms but different repro steps (which I can't replicate because of Honi's dependencies) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8942#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8942: Duplicate symbol error when loading an archive twice -----------------------------------+------------------------------------ Reporter: gelisam | Owner: simonmar Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: GHCi crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+------------------------------------ Changes (by simonpj): * status: new => patch Comment: Simon M, might you review? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8942#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8942: Duplicate symbol error when loading an archive twice
-----------------------------------+------------------------------------
Reporter: gelisam | Owner: simonmar
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Runtime System | Version: 7.6.3
Resolution: | Keywords:
Operating System: MacOS X | Architecture: Unknown/Multiple
Type of failure: GHCi crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-----------------------------------+------------------------------------
Comment (by Simon Marlow

#8942: Duplicate symbol error when loading an archive twice -----------------------------------+------------------------------------ Reporter: gelisam | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: GHCi crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+------------------------------------ Changes (by simonmar): * owner: simonmar => * status: patch => new Comment: Still need a test for this -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8942#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8942: Duplicate symbol error when loading an archive twice -----------------------------------+------------------------------------ Reporter: gelisam | Owner: simonmar Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: GHCi crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+------------------------------------ Changes (by simonmar): * owner: => simonmar -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8942#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8942: Duplicate symbol error when loading an archive twice -----------------------------------+------------------------------------ Reporter: gelisam | Owner: simonmar Type: bug | Status: closed Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: MacOS X | Architecture: Unknown/Multiple Type of failure: GHCi crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+------------------------------------ Changes (by simonmar): * status: new => closed * resolution: => fixed Comment: can't repro when `DYNAMIC_GHC_PROGRAMS=YES`, so we can't create a test; closing the ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8942#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC