[GHC] #2972: ppc ghci segfaults at startup
GHC
cvs-ghc at haskell.org
Mon Aug 13 20:37:02 CEST 2012
#2972: ppc ghci segfaults at startup
------------------------+---------------------------------------------------
Reporter: cemeyer | Owner: pcapriotti
Type: bug | Status: patch
Priority: normal | Milestone: 7.6.1
Component: GHCi | Version: 7.5
Keywords: | Os: Linux
Architecture: powerpc | Failure: GHCi crash
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
------------------------+---------------------------------------------------
Comment(by erikd@…):
commit 3e6c9308777caf83122baef504028d619d3dd588
{{{
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date: Tue Jul 31 05:53:49 2012 +1000
Fix GHCi segfault during startup on linux-powerpc (#2972).
Slightly modified version of a patch from Ben Collins
<bcollins at ubuntu.com>
who did the final debugging that showed the segfault was being caused
the
memory protection mechanism.
Due to the requirement of "jump islands" to handle 24 bit relative
jump
offsets, GHCi on PowerPC did not use mmap to load object files like
the
other architectures. Instead, it allocated memory using malloc and
fread
to load the object code. However there is a quirk in the GNU libc
malloc
implementation. For memory regions over certain size (dynamic and
configurable), malloc will use mmap to obtain the required memory
instead
of sbrk and malloc's call to mmap sets the memory readable and
writable,
but not executable. That means when GHCi loads code into a memory
region
that was mmapped instead of malloc-ed and tries to execute it we get a
segfault.
This solution drops the malloc/fread object loading in favour of using
mmap and then puts the jump island for each object code module at the
end of the mmaped region for that object.
This patch may also be a solution on other ELF based powerpc systems
but does not work on darwin-powerpc.
rts/Linker.c | 37 +++++++++++++++++++++++++++++++++----
1 files changed, 33 insertions(+), 4 deletions(-)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2972#comment:32>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list