#8942 closed bug (fixed)

Duplicate symbol error when loading an archive twice

Reported by: gelisam Owned by: simonmar
Priority: normal Milestone:
Component: Runtime System Version: 7.6.3
Keywords: Cc: simonmar
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: GHCi crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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:

{-# LANGUAGE DeriveDataTypeable #-}
module Hello where

import Data.Typeable
data Hello = Hello deriving Typeable

Workaround

Use Cabal 1.16, which (also) installs object files.

Attachments (3)

no_archive_doubleload.patch (2.9 KB) - added by gelisam 12 months ago.
Hello.hs (114 bytes) - added by gelisam 12 months ago.
hello.cabal (178 bytes) - added by gelisam 12 months ago.

Download all attachments as: .zip

Change History (9)

Changed 12 months ago by gelisam

Changed 12 months ago by gelisam

Changed 12 months ago by gelisam

comment:1 Changed 12 months ago 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)

comment:2 Changed 12 months ago by simonpj

  • Status changed from new to patch

Simon M, might you review?

Simon

comment:3 Changed 12 months ago by Simon Marlow <marlowsd@…>

In ee481ffbd70e3ac3586bb7ab92f276e509a3579e/ghc:

Ignore repeated loads of the same archive (#8942)

comment:4 Changed 12 months ago by simonmar

  • Owner simonmar deleted
  • Status changed from patch to new

Still need a test for this

comment:5 Changed 12 months ago by simonmar

  • Owner set to simonmar

comment:6 Changed 10 months ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

can't repro when DYNAMIC_GHC_PROGRAMS=YES, so we can't create a test; closing the ticket.

Note: See TracTickets for help on using tickets.