[GHC] #8935: Obscure linker bug leads to crash in GHCi
GHC
ghc-devs at haskell.org
Tue Apr 29 20:58:56 UTC 2014
#8935: Obscure linker bug leads to crash in GHCi
-------------------------------------+------------------------------------
Reporter: simonmar | Owner: simonmar
Type: bug | Status: new
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 dagit):
I haven't tested if I have the crash on my system, but suspect you're
seeing something to do with weak symbols. On my system, Fedora 19, I see
that glibc defines environ as a weak symbol and gives it the same address
that your libgmp check reports.
I modified your C program slightly so that it takes the paths in `argv[1]`
and `argv[2]`:
{{{
$ ./check-environ /usr/lib64/libgmp.so /usr/lib64/libpthread.so
environ = 0x601058
dlsym(deflt, "environ") = 0x601058
dlsym("libgmp", "environ") = 0x31e45bd508
dlsym("libpthread", "environ") = 0x601058
}}}
My libgmp doesn't define environ so it must find it in libc, and indeed:
{{{
$ readelf -Wa /usr/lib64/libc.so.6 | grep environ
00000031e45b9dd8 0000011900000006 R_X86_64_GLOB_DAT 00000031e45bd508
_environ + 0
00000031e45b9ea0 0000050000000006 R_X86_64_GLOB_DAT 00000031e45bd508
__environ + 0
281: 00000031e45bd508 8 OBJECT WEAK DEFAULT 33
_environ@@GLIBC_2.2.5
956: 00000031e45bd508 8 OBJECT WEAK DEFAULT 33
environ@@GLIBC_2.2.5
1280: 00000031e45bd508 8 OBJECT GLOBAL DEFAULT 33
__environ@@GLIBC_2.2.5
349: 00000031e45bbe70 8 OBJECT LOCAL DEFAULT 33 last_environ
1813: 0000000000000000 0 FILE LOCAL DEFAULT ABS environ.c
4539: 00000031e4238a10 1122 FUNC LOCAL DEFAULT 12
__add_to_environ
5707: 00000031e45bd508 8 OBJECT WEAK DEFAULT 33 _environ
6374: 00000031e45bd508 8 OBJECT GLOBAL DEFAULT 33 __environ
6483: 00000031e45bd508 8 OBJECT WEAK DEFAULT 33 environ
}}}
I suspect that the way you're searching for the symbol needs to look for a
(the?) strong binding first. I hope that helps.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8935#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list