[GHC] #8124: Possible leaks when using foreign export.

GHC ghc-devs at haskell.org
Mon Aug 12 17:25:26 CEST 2013


#8124: Possible leaks when using foreign export.
------------------------------+--------------------------------------------
       Reporter:  augustss    |             Owner:
           Type:  bug         |            Status:  new
       Priority:  normal      |         Milestone:
      Component:  Runtime     |           Version:  7.6.3
  System                      |  Operating System:  Unknown/Multiple
       Keywords:              |   Type of failure:  Runtime performance bug
   Architecture:              |         Test Case:
  Unknown/Multiple            |          Blocking:
     Difficulty:  Unknown     |
     Blocked By:              |
Related Tickets:              |
------------------------------+--------------------------------------------
 When a Haskell function exported with foreign export is called from
 outside Haskell a new Task may be allocated for it.
 There will be one Task allocated for each OS thread calling into Haskell
 (this happens in rts_lock()).  This Task is, by design, never deallocated.
 This works fine with a small number of threads, but if the external caller
 generates a lot of threads that die the Haskell RTS will just get more and
 more Task objects that are never freed.  The Task also contains a
 condition variable and a mutex, which incurs a HANDLE leak on Windows.

 I don't see an elegant fix to this, but the attached code remembers the OS
 thread for "incall" Task, and every so often (every 100 Tasks created) if
 will scan the Tasks looking for ones where the OS thread is dead, and
 remove these.
 The fix only works on Windows, I'm afraid.

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




More information about the ghc-tickets mailing list