[GHC] #7655: 7.6.2 Segmentation Fault/Bus Error in large exponentation
GHC
ghc-devs at haskell.org
Mon Jul 28 00:13:54 UTC 2014
#7655: 7.6.2 Segmentation Fault/Bus Error in large exponentation
-------------------------------------+----------------------------------
Reporter: Doug310 | Owner:
Type: bug | Status: infoneeded
Priority: normal | Milestone: 7.8.4
Component: GHCi | Version: 7.8.1-rc1
Resolution: | Keywords: exponentiation
Operating System: MacOS X | Architecture: x86_64 (amd64)
Type of failure: GHCi crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Revisions: |
-------------------------------------+----------------------------------
Comment (by rwbarton):
Thanks, that was helpful.
GMP does large temporary allocations in, for example, `mpn_mul`. Somehow,
we are configuring GMP to use `alloca` for temporary allocations. In the
most recent report, we happened to `alloca` past the stack guard page and
a malloc guard page, and then we crashed when we wrote into the
"allocated" memory that was actually the malloc guard page. (Note that the
"Stack" VM region is not actually the stack, it's a stack guard page.) In
the original report, it's hard to tell what's going on with no symbols
(due to the old ghci linker) but it looks like we may have `alloca`ed
directly into the stack guard page.
I imagine that we only saw this in ghci because non-threaded programs have
larger stack areas (and maybe no guard pages).
GMP's temporary allocation method is controlled by the CPP symbols
`WANT_TMP_ALLOCA`, `WANT_TMP_REENTRANT` etc. I don't understand how it is
happening that we build with `WANT_TMP_ALLOCA` when (per `configure.in`)
the default setting for `--enable-alloca` is `reentrant`. But I was able
to confirm from examining `libHSinteger-gmp-0.5.1.0-ghc7.8.3.dylib` that
it is using `alloca`, and mzero also provided the
[http://lpaste.net/108250 config.h] file from his build of GHC which
includes `#define WANT_TMP_ALLOCA 1`.
`WANT_TMP_REENTRANT` is the default, and what Debian's build of libgmp
uses, so we should just use that.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7655#comment:31>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list