[GHC] #15574: C wrappers for Haskell foreign exports don't have finalizers (causes memory leak).

#15574: C wrappers for Haskell foreign exports don't have finalizers (causes memory leak). -------------------------------------+------------------------------------- Reporter: Valoisa | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.0.1 (FFI) | Keywords: | Operating System: Windows Architecture: | Type of failure: Runtime Unknown/Multiple | performance bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- For each foreign export RTS creates a static C wrapper, which is initialized on {{{DLL_PROCESS_ATTACH}}}, but it has no finalizer/destructor to be called during {{{DLL_PROCESS_DETACH}}}. So it will stay alive till the program termination. That's why if one uses a Haskell DLL in their C/C++ project, **consumed memory is not fully released after freeing the library**. [[br]][[br]] There are four files attached to this ticket. * **HaskellExports.hs** contains exact one foreign export function; * **CWrapper.cpp** is supposed to contain wrappers to the Haskell functions, described in ''HaskellExports.hs'', but it doesn't because they make no difference; * **main.cpp**: here in an endless loop the DLL (built with the help of the script below) is loaded and freed at once. Launched program is crashed in a while (because it runs out of memory); * **build.sh** is a script for building the library. [[br]] The main program was built with MSVC 2015. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15574 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15574: C wrappers for Haskell foreign exports don't have finalizers (causes memory leak). -------------------------------------+------------------------------------- Reporter: Valoisa | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler (FFI) | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Valoisa): * Attachment "HaskellExports.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15574 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15574: C wrappers for Haskell foreign exports don't have finalizers (causes memory leak). -------------------------------------+------------------------------------- Reporter: Valoisa | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler (FFI) | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Valoisa): * Attachment "HaskellExports.2.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15574 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15574: C wrappers for Haskell foreign exports don't have finalizers (causes memory leak). -------------------------------------+------------------------------------- Reporter: Valoisa | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler (FFI) | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Valoisa): * Attachment "CWrapper.cpp" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15574 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15574: C wrappers for Haskell foreign exports don't have finalizers (causes memory leak). -------------------------------------+------------------------------------- Reporter: Valoisa | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler (FFI) | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Valoisa): * Attachment "main.cpp" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15574 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15574: C wrappers for Haskell foreign exports don't have finalizers (causes memory leak). -------------------------------------+------------------------------------- Reporter: Valoisa | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler (FFI) | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Valoisa): * Attachment "build.sh" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15574 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15574: C wrappers for Haskell foreign exports don't have finalizers (causes memory leak). -------------------------------------+------------------------------------- Reporter: Valoisa | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler (FFI) | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Valoisa): {{{HaskellExports.2.hs}}} is the same as {{{HaskellExports.hs}}}, it was attached accidentally (no idea how to remove it). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15574#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC