#5748: ghci segfault on OS X after dlsym failed lookup
---------------------------------+------------------------------------------
Reporter: gwright | Owner: gwright
Type: bug | Status: new
Priority: normal | Milestone:
Component: GHCi | Version: 7.2.1
Keywords: | Os: MacOS X
Architecture: Unknown/Multiple | Failure: GHCi crash
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by gwright):
Well, this just gets most interesting. I patched {{{rts/Linker.c}}} to
error out if lookupSymbol returned NULL and it broke the build.
The problem is a single failed symbol lookup, {{{approx_tab}}} defined in
HSinteger-gmp-0.3.0.0.o. The symbol is defined:
{{{
gwright-macbook> nm HSinteger-gmp-0.3.0.0.o | grep approx_tab
00000000000672c0 d approx_tab
}}}
but is missing a leading underscore. On OS X, the {{{lookupSymbol}}}
function always strips off the first character, without first checking if
it is an underscore. (Amusingly, there is an assertion to test that the
leading character of a symbol is an underscore. Evidently assertions are
seldom turned on during a compiler build, otherwise this would have shown
up earlier.)
I changed the linker to produce a {{{debugBelch}}} instead of an error
after a failed lookup. The bug occurs a number of times while building
ghc, probably every time TH invokes ghci.
Instead of mucking about with {{{gmp}}}, I'm going to try patching
{{{lookupSymbol}}} to check for the leading underscore and not strip the
first character if it is not there.
I also poked around the {{{gmp}}} mailing list and saw ominous mention of
{{{approx_tab}}} being treated specially, to work around a Darwin "linker
bug".
Verily, a maze of twisty passages, all alike.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5748#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs