
#8935: Obscure linker bug leads to crash in GHCi
------------------------------------+-------------------------------------
Reporter: simonmar | Owner: simonmar
Type: bug | Status: new
Priority: high | Milestone: 7.8.2
Component: Runtime System | Version: 7.6.3
Keywords: | Operating System: Unknown/Multiple
Architecture: Unknown/Multiple | Type of failure: GHCi crash
Difficulty: Rocket Science | Test Case:
Blocked By: | Blocking:
Related Tickets: |
------------------------------------+-------------------------------------
I have a build of GHC (with `DYNAMIC_GHC_PROGRAMS=NO`) that exhibits the
following crash:
{{{
$ ghc -e 'System.Environment.getEnvironment'
<segfault>
}}}
I tracked it down, eventually, to a bad reference to the symbol `environ`
from `__hscore_environ` in `libraries/base/includes/HsBase.h`. Somehow,
`environ` had got linked to the wrong address.
Lots more investigation lead me to discover this: `internal_dlsym()` in
`Linker.c` tries to look up a symbol in all the different shared libraries
we have loaded so far, one by one. (see
be497c202b790999c3fd0ddc4a4176b8cf6acf7e). Unfortunately, this seems to
break things in my case. Here's a simple test program that works on
Ubuntu 12.04:
{{{
#include