Commit 2a6f193b authored by Simon Marlow's avatar Simon Marlow

Fix a bug introduced with allocation counters

parent a2c0a8dd
......@@ -2233,6 +2233,9 @@ suspendThread (StgRegTable *reg, rtsBool interruptible)
task->incall->suspended_tso = tso;
task->incall->suspended_cap = cap;
// Otherwise allocate() will write to invalid memory.
cap->r.rCurrentTSO = NULL
ACQUIRE_LOCK(&cap->lock);
suspendTask(cap,task);
......
......@@ -209,3 +209,7 @@ test('T8083',
compile_and_run,
['T8083_c.c'])
test('ffi023', [ omit_ways(['ghci']),
extra_clean(['ffi023_c.o']),
extra_run_opts('1000 4') ],
compile_and_run, ['ffi023_c.c'])
-- Tests for a bug fixed in
module Main where
import System.Environment
import Control.Concurrent
import Control.Monad
foreign import ccall safe "out"
out :: Int -> IO Int
foreign export ccall "incall" incall :: Int -> IO Int
incall :: Int -> IO Int
incall x = return $ x + 1
main = do
[n, m] <- fmap (fmap read) getArgs
ms <- replicateM m $ do
v <- newEmptyMVar
forkIO $ do mapM out [0..n]; putMVar v ()
return v
mapM_ takeMVar ms
#include "ffi023_stub.h"
#include "HsFFI.h"
#include "Rts.h"
HsInt out (HsInt x)
{
performMajorGC();
return incall(x);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment