Opened 4 years ago

Closed 2 years ago

#8614 closed bug (fixed)

Duplicate symbol error when loading text twice

Reported by: nh2 Owned by:
Priority: normal Milestone:
Component: Runtime System (Linker) Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHCi crash Test Case:
Blocked By: Blocking:
Related Tickets: #7030 Differential Rev(s):
Wiki Page:

Description

We are developing some FFI binding to some Kinect Camera library, and came across the following:

GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> import Honi
Prelude Honi> import Honi.Types
Prelude Honi Honi.Types> initialize 2
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package bytestring-0.10.0.2 ... linking ... done.
Loading package text-0.11.3.1 ... linking ... done.
Loading package honi-0.1.0.0 ... can't load .so/.DLL for: libfreenect.so (libfreenect.so: cannot open shared object file: No such file or directory)
Prelude Honi Honi.Types> Right [d] <- getDeviceList
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package bytestring-0.10.0.2 ... linking ... done.
Loading package text-0.11.3.1 ... 

GHCi runtime linker: fatal error: I found a duplicate definition for symbol
   __stginit_textzm0zi11zi3zi1_DataziText
whilst processing object file
   /home/niklas/.cabal/lib/x86_64-linux-ghc-7.6.3/text-0.11.3.1/libHStext-0.11.3.1.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.

Apparently, ghci has no problem linking packages like array and deepseq twice, but when it comes across loading text another time, we get this duplicate symbol error.

Does this make sense? Why does it not detect that text is already linked, like for the other packages?

Change History (5)

comment:1 Changed 3 years ago by thomie

Status: newinfoneeded

I tried cabal install honi, but am getting the error:

* Missing C libraries: OpenNI2, freenect

Where do I get those, for Ubuntu 14.04. Or better: could you construct a small program that doesn't use honi to reproduce this issue? Thanks.

comment:2 Changed 3 years ago by thomie

comment:3 Changed 2 years ago by ezyang

Component: CompilerRuntime System (Linker)

So, it turns out that there is a linking failure in the pasted transcript. So it looks like the bug is that we are not properly unloading the objects we loaded prior to the failure; namely, text has something which is not unloaded.

comment:4 Changed 2 years ago by ezyang

OK, so I tried to reproduce with a very minimal example, using the following steps:

  1. I took honi, and edited it so it had no dependence on the actual libraries. I installed it, and then manually edited package config so that it had a dependency on a non-existent dynamic library.
  1. Then I opened GHCi, and induced GHCi to attempt to load the packages twice (failing because this last package couldn't load the non-existent package.)

However, text reloaded fine for me. Granted, it was text-1.2.1.3 but I don't think there is any substantive difference here.

So yes, we are going to need more information to reproduce and solve this bug.

comment:5 Changed 2 years ago by nh2

Resolution: fixed
Status: infoneededclosed

OK, so first on how to get the deps:

  • freenect: apt-get install libfreenect-dev on Ubuntu 14.04
  • OpenNI2: git clone https://github.com/occipital/OpenNI2.git, cd OpenNI2, git checkout origin/develop

Then I compile with $HOME/.local/bin/cabal install --extra-include-dirs=$HOME/src/OpenNI2/Include/ --extra-lib-dirs=$HOME/src/OpenNI2/Bin/x64-Release/

However, I have tried this now with GHC 7.10.2, and cabal-install 1.22.6.0, and can no longer reproduce the issue.

My output:

➤ ghci
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
Prelude> import Honi
Prelude Honi> import Honi.Types 
Prelude Honi Honi.Types> initialize 2
StatusOK

Trying the same with GHC 7.8:

~/.stack/programs/x86_64-linux/ghc-7.8.4/bin/ghc --interactive 
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> import Honi
Prelude Honi> import Honi.Types 
Prelude Honi Honi.Types> initialize 2
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package binary-0.7.1.0 ... linking ... done.
Loading package text-1.2.1.3 ... linking ... done.
Loading package honi-0.1.0.0 ... linking ... done.
StatusOK

So I believe this was probably fixed with the linker improvements in GHC 7.8 (I reported the bug against 7.6).

Thanks for poking at this bug, I'm happy to find that it is fixed.

Note: See TracTickets for help on using tickets.