On Wed, May 8, 2013 at 6:54 PM, Niklas Hambüchen <m...@nh2.me> wrote: > I have an annoying bug in a C binding that can be triggered like this: > > > handle <- open ... > > prep <- makePreparedStatement handle "INSERT ..." > > performGC > > runStatement prep > > close handle > > If I run these steps one by one in ghci, garbage ends up in my handle as > expected. > > However, if I "let main = do ..." this whole block in order to pack it > in a test case, it does not happen, neither in ghci nor ghc. > > What might be the special magic in ghci's REPL that allows me to trigger > my bug so easily there?
One thing to investigate: Thread Local Storage By default ghci puts each action you run into a thread and executes it. If the underlying C code stores something (or accesses it) from thread local storage, then you will run into issues like this. Try starting ghci with -fno-ghci-sandbox. If the bad behavior goes away there, try running each step of your test case inside a forkIO from ghc with the threaded RTS. If the problem disappears in ghci but shows up with forkIO, then it's a pretty good indicator that it's related to the way the C code uses thread local storage. I hope that helps, Jason _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe