[GHC] #8935: Obscure linker bug leads to crash in GHCi
GHC
ghc-devs at haskell.org
Mon May 5 20:37:24 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 simonmar):
`libgmp` is not symbolic on my system either.
Symbol information and relocs for the program:
{{{
$ objdump --syms --dynamic-syms --reloc --dynamic-reloc ./a.out | grep
envir
0000000000000000 l df *ABS* 0000000000000000 check-
environ.c
0000000000601060 w O .bss 0000000000000008
environ@@GLIBC_2.2.5
0000000000601060 g O .bss 0000000000000008
__environ@@GLIBC_2.2.5
0000000000601060 w DO .bss 0000000000000008 GLIBC_2.2.5 _environ
0000000000601060 w DO .bss 0000000000000008 GLIBC_2.2.5 environ
0000000000601060 g DO .bss 0000000000000008 GLIBC_2.2.5 __environ
0000000000601060 R_X86_64_COPY __environ
}}}
Note there are 3 symbols at the same location (`environ`, `_environ`, and
`__environ`). The first two are weak, the third is global. The third is
also a copy reloc, which means its contents is copied to this location
when the program starts up.
Symbol information and relocs for libc:
{{{
$ objdump --syms --dynamic-syms --reloc --dynamic-reloc /lib/x86_64-linux-
gnu/libc-2.17.so | grep envir
00000000003c44e8 w DO .bss 0000000000000008 GLIBC_2.2.5 _environ
00000000003c44e8 w DO .bss 0000000000000008 GLIBC_2.2.5 environ
00000000003c44e8 g DO .bss 0000000000000008 GLIBC_2.2.5 __environ
00000000003c0de0 R_X86_64_GLOB_DAT _environ
00000000003c0ea8 R_X86_64_GLOB_DAT __environ
}}}
Again we have 3 symbols at the same location, all 8 bytes long.
There are no mentions of any `environ` symbol in `libgmp`'s symbol table
or relocations.
`LD_DEBUG=all` shows a normal lookup like this:
{{{
23419: symbol=environ; lookup in file=./a.out [0]
23419: binding file ./a.out [0] to ./a.out [0]: normal symbol
`environ'
}}}
but the lookup in `libgmp` looks like this:
{{{
23419: symbol=environ; lookup in file=/usr/lib/x86_64-linux-
gnu/libgmp.so [0]
23419: symbol=environ; lookup in file=/lib/x86_64-linux-
gnu/libc.so.6 [0]
23419: binding file /usr/lib/x86_64-linux-gnu/libgmp.so [0] to
/lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `environ'
}}}
I still have no idea why the lookup in `libgmp` is behaving differently
from the others.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8935#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list