[GHC] #8935: Obscure linker bug leads to crash in GHCi

GHC ghc-devs at haskell.org
Mon May 5 21:52:22 UTC 2014


#8935: Obscure linker bug leads to crash in GHCi
-------------------------------------+------------------------------------
        Reporter:  simonmar          |            Owner:  simonmar
            Type:  bug               |           Status:  infoneeded
        Priority:  high              |        Milestone:  7.8.3
       Component:  Runtime System    |          Version:  7.8.1-rc2
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  GHCi crash        |       Difficulty:  Rocket Science
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by trommler):

 Let's look at comment:12 again. We see that even for symbols defined in
 libgmp.so the dynamic linker searches ./check-environ (and libdl and libc
 and ld-linux) before it finally finds the symbol in libgmp.so

 {{{
       5823:     symbol=__gmp_default_free;  lookup in file=./check-environ
 [0]
       5823:     symbol=__gmp_default_free;  lookup in
 file=/lib64/libdl.so.2 [0]
       5823:     symbol=__gmp_default_free;  lookup in
 file=/lib64/libc.so.6 [0]
       5823:     symbol=__gmp_default_free;  lookup in file=/lib64/ld-
 linux-x86-64.so.2 [0]
       5823:     symbol=__gmp_default_free;  lookup in
 file=/usr/lib64/libgmp.so [0]
 }}}

 And then for {{{environ}}} the search starts in {{{libgmp.so}}}. Perhaps
 because {{{environ}}} is a weak symbol.

 It seems that openSUSE ignores the weak attribute of symbols in the
 dynamic linker and treats them as strong and hence starts the search in
 {{{./check-environ}}}. This seems to be correct as Drepper
 [http://www.akkadia.org/drepper/dsohowto.pdf] says on p. 6: "Note that a
 definition in a DSO being weak has no effects. Weak definitions only play
 a role in static linking." It seems Ubuntu and Fedora do not agree.

 There is also an environment variable {{{LD_DYNAMIC_WEAK}}} (see ld.so(8))
 to allow overriding weak symbols. Is that environment variable set on your
 systems?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8935#comment:22>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list