Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a "duplicate definition for symbol" error in GHCI

Tags:

haskell

ghci

I have a problem with ghci and I need an advice on how to debug it. The problem is that when I execute a function from my imported project I have a duplicate definition error and ghci exits because it can't continue:

> ghci -v0 --interactive -ignore-dot-ghci -isrc -idist/build/autogen tests/System/Console/Hawk/PreludeTests.hs -no-user-package-db -package-db /mnt/git/hawk/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d
*System.Console.Hawk.PreludeTests> test [] "1" ""


GHCi runtime linker: fatal error: I found a duplicate definition for symbol
   __stginit_stringsearchzm0zi3zi6zi5_DataziByteStringziSearch
whilst processing object file
   /mnt/git/hawk/.cabal-sandbox/lib/x86_64-linux-ghc-7.6.3/stringsearch-0.3.6.5/libHSstringsearch-0.3.6.5.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.

The problem is that I can't find where this is happening. The symbol is unique in my cabal sandbox:

> for f in `find .cabal-sandbox -type f -iname "*.a"`; do nm $f | grep '__stginit_stringsearchzm0zi3zi6zi5_DataziByteStringziSearch$'; done
0000000000000000 D __stginit_stringsearchzm0zi3zi6zi5_DataziByteStringziSearch

so probably the stringsearch library is somehow loaded two times, but ghci is vague about it.

I would like to know if there is a way to debug this or, at least, to get more informations on the error before ghci kills itself. I already tried to change verbosity but I still get no informations.

like image 945
mariop Avatar asked Mar 13 '14 17:03

mariop


1 Answers

Often this can occur when you are indirectly depending on two different versions of a library that both export the same symbol. This could occur, for example, if you also had a library from outside your sandbox (e.g. in the global package db) that depended on a stringsearch from there.

Additionally, to get more debug info, you should pass a flag indicating a higher verbosity.

like image 74
sclv Avatar answered Nov 15 '22 21:11

sclv