takeMVar causes 'Segentation fault' when called from C

Krasimir Angelov ka2_mail at yahoo.com
Fri Aug 30 13:56:38 EDT 2002


Following example causes 'Segentation fault' under
Linux (Mandrake). Under Windows it works well.

---------------------------------------------------
module Main where

import Control.Concurrent.MVar
import System.IO.Unsafe

main = cfun >> main

foreign export ccall hfun :: IO ()
foreign import ccall cfun :: IO ()

{-# NOINCLUDE counter #-}
counter :: MVar Int
counter = unsafePerformIO (newMVar 0)

hfun = do
	n <- takeMVar counter
	print n
	putMVar counter (n+1)
------------------------------------------------------

#include "Main_stub.h"

void cfun ()
{
	hfun();
}


Krasimir

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com



More information about the Glasgow-haskell-bugs mailing list