[GHC] #8199: Get rid of HEAP_ALLOCED

GHC ghc-devs at haskell.org
Thu Feb 13 06:37:40 UTC 2014


#8199: Get rid of HEAP_ALLOCED
----------------------------+----------------------------------------------
        Reporter:  ezyang   |            Owner:  ezyang
            Type:  feature  |           Status:  new
  request                   |        Milestone:  7.10.1
        Priority:  normal   |          Version:  7.7
       Component:           |         Keywords:
  Compiler                  |     Architecture:  Unknown/Multiple
      Resolution:           |       Difficulty:  Project (more than a week)
Operating System:           |       Blocked By:  5435
  Unknown/Multiple          |  Related Tickets:
 Type of failure:           |
  None/Unknown              |
       Test Case:           |
        Blocking:           |
----------------------------+----------------------------------------------

Comment (by ezyang):

 I discovered an interesting flaw in the current design while debugging a
 segfault today. The problem goes like this: currently, on a per-module
 basis we generate an extra C file responsible for registering
 staticclosureinds with the initialization loop which will run at the
 beginning of the file.  The implicit assumption being made here, of
 course, is that a statically linked module will be loaded atomically
 together, all of the object files being brought in for the ride.

 However, this is NOT TRUE when split objects are being used! In this case,
 it is quite possible for the object file containing the initialization
 function to *not* be loaded, while another split object which uses an
 indirection does get loaded. In this case, the static closure never gets
 initialized, and we'll get a segfault if we try to use it.

 How can we fix this? One possibility is, when splitting objects, to ensure
 if the staticclosureinds section is nonzero, then we have a reference to
 the initialization function somewhere else in the resulting object file,
 so it gets loaded in. However, it's not even clear that the starts/ends
 trick is going to even keep working, unless the splitter is very careful.

 Another possibility is to axe the initialization function, and try harder
 to detect the staticclosureinds section at runtime. Doing this properly in
 a cross-platform way is tricky (I originally tried to do it with linker
 scripts, but gave up when it (1) didn't work, and (2) wasn't going to work
 on other platforms.)

 I'll upload an up-to-date patchset for GHC 7.8 at some point. There's been
 a recent change to integer-gmp which needs to be updated for HEAP_ALLOCED.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8199#comment:20>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list