#3215: Calling freeHaskellFunPtr on the current function
----------------------------+-----------------------------------------------
Reporter: cmcq | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Runtime System | Version: 6.10.3
Severity: normal | Resolution: invalid
Keywords: | Testcase:
Os: Linux | Architecture: x86
----------------------------+-----------------------------------------------
Changes (by cmcq):
* status: new => closed
* resolution: => invalid
Comment:
This was just a Valgrind problem with self-modifying code. "--smc-
check=all" fixes it. I think that due to the LIFO free list used by
rts/Stable.c, the functions are reversed the second time round. Because of
Valgrind's caching, the finalizer was being called first.
I noticed this paragraph in rts/Adjustor.c, so I assume that calling
freeHaskellFunPtr on the current function IS allowed.
When generating an adjustor thunk that uses the C calling
convention, we have to make sure that the thunk kicks off
the process of jumping into Haskell with a tail jump. Why?
Because as a result of jumping in into Haskell we may end
up freeing the very adjustor thunk we came from using
freeHaskellFunctionPtr(). Hence, we better not return to
the adjustor code on our way out, since it could by then
point to junk.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3215#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs