I'm running into some problems with finalizers in ghc-4.08.1 on Linux and
FreeBSD. I'm not certain yet whether the bug is mine (bad Greencard code) or
GHC's but thought I'd describe the problem and see if it triggered any ideas.
My program is a compiler. It does a lot of allocation (and, hence, GC).
Towards the end of compilation, it calls a greencarded library to solve a graph
problem. This generates a fairly large number of foreign pointers (over 2000)
most of which become free at about the same time. Sometime after the freeing
starts and immediately after a garbage collection, the free routine is called
with a bogus pointer as an argument.
Building with ghc-4.07 (built some months ago from the repository) instead I
don't see this problem.
The bug could be in my code but the dependence on compiler version suggests
that GHC could be to blame. Here's a few guesses as to what could be going
wrong:
1) What happens if a GC occurs while running the finaliser thread?
This seems a bit tricky so I'm a little suspicious.
2) What happens if a GC occurs whilst preparing the thread that calls the
finalisers?
It looks like it allocates an array, allocates a thread, pushes a closure on
the thread and schedules the thread. Handling a GC during this time sounds
really, really tricky so I'm very suspicious.
3) Some code that manipulates weak pointers could be confusing things.
Less likely since you'd expect problems to show up fairly quickly.
Well, that's all I could think of. Let me know if you think any of these are
at all likely. I'll whack on this some more tomorrow if I don't have to go
skiing instead.
--
Alastair Reid [EMAIL PROTECTED] http://www.cs.utah.edu/~reid/
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs